Passing Window Handles?
-
How does one pass the parent dialog box's handle to the contructor of a child dialog box that it creates? I need to access the public methods of the parent dialog box from the child dialog box. Thanks.
When you create the child dialog, pass the pointer of the parent dialog For example, call this from a parent dialog
void CParentDlg::SomeFunc()
{
CChildDlg dlg(this);
dlg.DoModal();
.
.
}Now call GetParent() to access the parent dialog
CParentDlg* pParentWnd = (CParentDlg*)GetParent();
Now use pParentWnd to access the public functions from child dialog Hope this helps // Fazlul
Get RadVC today! Play RAD in VC++ http://www.capitolsoft.com
-
How does one pass the parent dialog box's handle to the contructor of a child dialog box that it creates? I need to access the public methods of the parent dialog box from the child dialog box. Thanks.
you can use GetParent()
-
How does one pass the parent dialog box's handle to the contructor of a child dialog box that it creates? I need to access the public methods of the parent dialog box from the child dialog box. Thanks.
Hello, the codegurus around the world.;) GetParent() is one way, but not so much technically. So, pass the handle of parent of the constructor.
CChildDlg dlg (this); dlg.DoModal();
And the constructor of CChildDlg;
ChildDlg::ChildDlg (CWnd\* pWnd) { ASSERT(pWnd); //Declare CWnd\* m\_pParent as the private member value; m\_pParent = pWnd; }
Good Luck! Have a nice day!
-Masaaki Onishi-