Dialog Pointers to another dialog

Hi Experts,

I have created a modeless dialog that is created in a modal dialog.  In the modeless dialog I have a listctrl
of names that I want to send back to the modal dialog.  However I need to set the pointer pTheApp->pDialog back to the modal dialog in order to tell the dialog pointer that it is not empty (NULL) so I can send a message to the modal dialog's functions.

JPM2002Asked:
Who is Participating?
 
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
In the modal dialog
pTheApp->pDialog = this;


To send a message
pTheApp->pDialog->SendMessage(MY_MESSAGE, WPARAM, LPARAM);
No need to store HWND's or use FromHandlePermanent or the like.
0
 
umamaheswari_KCommented:
you get the main dialog(modal dialog) handle and store it .

HANDLE hdl=this->m_hWnd;

in second dlg
CDlg *pdlg=(CDlg*) FromHandlePermanent(hdl);
//////
pdlg-> ////////Add ur code for listctrl values
////////////////
send message to the main dialog

pdlg->SendMessage(WM_INITDIALOG,0,0);


this

0
 
JPM2002Author Commented:
U K,

I changed it to

CDialog *pdlg=(CDialog*) CWnd::FromHandlePermanent(pTheApp->hdl);
  without the CWind:: would error out as 'FromHandlePermanent' : undeclared identifier

however I also get this error
'FromHandlePermanent' : cannot convert parameter 1 from 'void *' to 'struct HWND__ *'

no way I know to fix this.

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
alb66Commented:
Change the following line:

 HANDLE hdl=this->m_hWnd;

to

HWND hdl=this->m_hWnd;
0
 
alb66Commented:
You can also store directly  the CDialog* instead of the handle:

// HANDLE hdl=this->m_hWnd;
CDialog * pDialog = this



//CDialog *pdlg=(CDialog*) CWnd::FromHandlePermanent(pTheApp->hdl);
CDialog * = pTheApp->pDialog;
0
 
JPM2002Author Commented:
Andy, Alb, UK

Thanks for your solutions. However I have to admit using and trying Andy's solution was the easiest and most elegant of the 3.
I hence give Andy the major number of points.  
I thanks you all.

JM
0
 
JPM2002Author Commented:
see above
0
All Courses

From novice to tech pro — start learning today.