jpw1
asked on
How do I get the CWnd from a dialog box?
I use VC++.
I want to crate a Model less dialog box from another dialog box
I use following code inside a dialog box.
CGrassGame grassG = new CGrassGame();
grassG.Create(IDD_DIALOG_G RASS_FIELD , ????);
grassG.ShowWindow(SW_SHOW) ;
How do I get the CWnd from a dialog box?
Janaka
I want to crate a Model less dialog box from another dialog box
I use following code inside a dialog box.
CGrassGame grassG = new CGrassGame();
grassG.Create(IDD_DIALOG_G
grassG.ShowWindow(SW_SHOW)
How do I get the CWnd from a dialog box?
Janaka
grassG is instance of CWnd-derived class ( CGrassGame -> CDialog -> CWnd ). You can apply any CWnd function to it.
ASKER
To create and show the dialog box as model I must pass the CWnd to it.
grassG.Create(IDD_DIALOG_G RASS_FIELD , ????);
since I am inside another dialog how do I get it?
(what should I put for ????)
grassG.Create(IDD_DIALOG_G
since I am inside another dialog how do I get it?
(what should I put for ????)
grassG.Create(IDD_DIALOG_G RASS_FIELD , this);
ASKER
it gives this error when i try it ...
(3221) : error C2664: 'int __thiscall CDialog::Create(const char *,class CWnd *)' : cannot convert parameter 1 from 'const int' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
Creating browse info file...
(3221) : error C2664: 'int __thiscall CDialog::Create(const char *,class CWnd *)' : cannot convert parameter 1 from 'const int' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
Creating browse info file...
Strange, such code fragment is always compiled in my projects. Try this:
grassG.Create(MAKEINTRESOU RCE(IDD_DI ALOG_GRASS _FIELD), this);
grassG.Create(MAKEINTRESOU
ASKER
No luck
VirtualBadmintonDoc.cpp
F:\Game Development\My Work\3D\14-Grass Field\VirtualBadminton\Vir tualBadmin tonDoc.cpp (3228) : error C2664: 'int __thiscall CDialog::Create(const char *,class CWnd *)' : cannot convert parameter 2 from 'class CVirtualBadmintonDoc *const ' to 'class
CWnd *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
Creating browse info file...
but if i use this it works ...
CGrassGame *grassG = new CGrassGame();
grassG->Create(IDD_DIALOG_ GRASS_FIEL D, NULL);
grassG->ShowWindow(SW_SHOW );
VirtualBadmintonDoc.cpp
F:\Game Development\My Work\3D\14-Grass Field\VirtualBadminton\Vir
CWnd *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
Creating browse info file...
but if i use this it works ...
CGrassGame *grassG = new CGrassGame();
grassG->Create(IDD_DIALOG_
grassG->ShowWindow(SW_SHOW
ASKER
Ok I found the problem …
I am calling this from document class so I can not pass <b>this</b>
What should I use instead of this?
I am calling this from document class so I can not pass <b>this</b>
What should I use instead of this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To find document's view use GetFirstViewPosition.
ASKER
Great !!
Is there a way to get the windows handle (HWND) of this dialog box inside it?
Is there a way to get the windows handle (HWND) of this dialog box inside it?
Every CWnd-derived class has member m_hWnd which is this window handle.
ASKER
Thanks ...