how do you get a handle to a modal dialog from outside of the dialogs procedure?
I need to be able to send messages to it.
Thanks.
Printable View
how do you get a handle to a modal dialog from outside of the dialogs procedure?
I need to be able to send messages to it.
Thanks.
Is this dialog part of your application? If so, just save its handle into a global variable, or into a data structure you have access to. Otherwise, you can use FindWindow.
Sometimes accessing a modal dialog is not that easy (ie in MFC using DoModal() ) as the dialog (DoModal call) does not return until the dialog has closed.
I find it easier to set a global variable (or local to the object that wants to send it messages, the 'caller').
I do this in the dialogs init or create message. May require you to send in a pointer to the 'caller'. This can be done by modifing the dialogs constructor.
Usually if you want the application to interact with the dialog, a modeless dialog is used.
I agree with novacain, better to use a modeless for true interaction with a program. It seems more suited to actually interacting with a dialog than with the more "static" dialog.