Dynamic runtime class and dialog based apps 
Author Message
 Dynamic runtime class and dialog based apps

Mike:

1. I'm really not sure why you got this error, but did you make sure to put
IMPLEMENT_DYNCREATE in the .cpp file of your dialog, in addition to
DECLARE_DYNCREATE in the .h file?

2. You really do not need DECLARE_DYNCREATE for dialogs because you are not
going to use dynamic creation (creation using CObject->CreateObject).
DECLARE_DYNMAMIC is sufficient for runtime class information. In fact the dialog
classes which MFC creates for you do not have either, though the base class
CDialog has DECLARE_DYNAMIC.

3. I think you are very confused:

(a) If you are in a dialog application then m_pMainWnd is your dialog, so I am
sure that calling GetActiveView() on it will return NULL. The code you have is
(as you say) clearly taken from a doc-view application, and is not appropriate
here.

(b) If you are just looking for a pointer to your dialog from a member function
of the dialog, why do you not just use the "this" pointer? Also, what do you
need this pointer for? You normally do not need this pointer unless you are
going to pass it as an argument to a contructor or function of another class (or
other object of the same class).

4. In my opinion an excellent inroductory book on MFC is Jeff Prosise
"Programming Windows 95 with MFC". You need to be comfortable with C++, but you
do not need previous knowledge of Windows programming in C.

HTH,

David Wilkinson

=================

Quote:

> Can someone explain a bit how to get a hold of a RUNTIME_CLASS object in a
> dialog based app?
> at least I think thats my problem

> here's what I'm doing

> class SMyDlg : public CDialog
> {

> public:
>     CMyDlg(CWnd* pParent = NULL); // generated for me
>     DECLARE_DYNCREATE(CMyDlg)

>     static CMyDlg *GetDlg(void)
>     .
>     .
>     .
> }

> CMyDlg* CMyDlg::GetDlg()
> {
> CFrameWnd *pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
> CView *pView = pFrame->GetActiveView();
> if(!pView)
>   return NULL;
> if(!pView->IsKindOf(RUNTIME_CLASS(CDialog)))
>   return NULL;

> return (CMyDlg *)pView;
> }

> This setup compiles fine but doesn't link, with an unresolved external
> symbol
> "public: virtual struct CRuntimeClass * __thiscall
> CMyDlg::GetRuntimeClass(void)const"

> what I'm trying to do is get a pointer to my dialog box from within a member
> class.

> Is there an easier way of doing this?

> I must admit I'm following along with an MFC/WinSock book,
> and I'm a little new to MFC (hell WinSock too).  So I got some of this code
> from an SDI based document, and I know that something is out of place here.

> Someone here must know of a good MFC book, btw,
> I've looked in a few places and haven't seen much that catches the eye.

> Thanks for any help

> Mike Kinsman

> remove the .spam to send an email



Thu, 16 Aug 2001 03:00:00 GMT  
 Dynamic runtime class and dialog based apps
Can someone explain a bit how to get a hold of a RUNTIME_CLASS object in a
dialog based app?
at least I think thats my problem

here's what I'm doing

class SMyDlg : public CDialog
{

public:
    CMyDlg(CWnd* pParent = NULL); // generated for me
    DECLARE_DYNCREATE(CMyDlg)

    static CMyDlg *GetDlg(void)
    .
    .
    .

Quote:
}

CMyDlg* CMyDlg::GetDlg()
{
CFrameWnd *pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
CView *pView = pFrame->GetActiveView();
if(!pView)
  return NULL;
if(!pView->IsKindOf(RUNTIME_CLASS(CDialog)))
  return NULL;

return (CMyDlg *)pView;

Quote:
}

This setup compiles fine but doesn't link, with an unresolved external
symbol
"public: virtual struct CRuntimeClass * __thiscall
CMyDlg::GetRuntimeClass(void)const"

what I'm trying to do is get a pointer to my dialog box from within a member
class.

Is there an easier way of doing this?

I must admit I'm following along with an MFC/WinSock book,
and I'm a little new to MFC (hell WinSock too).  So I got some of this code
from an SDI based document, and I know that something is out of place here.

Someone here must know of a good MFC book, btw,
I've looked in a few places and haven't seen much that catches the eye.

Thanks for any help

Mike Kinsman

remove the .spam to send an email



Thu, 16 Aug 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Resizing Dialog based app at runtime

2. Resizing a dialog based app based on its view's size

3. Modeless dialog in a dialog-based app

4. dialog within dialog based apps

5. Showing taskbar visible dialog from dialog based app

6. 2nd Dialog never appears in Dialog based app

7. Dialog-based app and modal dialog

8. HOWTO: hide dialog when a dialog-based app starts

9. dialog based app making modeless dialogs

10. PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app

11. Dialog-Based App and Main Dialog Problem

12. Destroy Dialog for Dialog based app

 

 
Powered by phpBB® Forum Software