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.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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



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.

Change the following line:

 HANDLE hdl=this->m_hWnd;


HWND hdl=this->m_hWnd;
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

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;
AndyAinscowFreelance 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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.

JPM2002Author Commented:
see above
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.