COM and ATL Dialogs
-
I have created an ATL project, inserted a Simple Object and an ATL Dialog via the ATL Object Wizard. Everything works great except for one thing. I don't have an interface to the Dialog. So, my client app can't interface with my dialog. The only thing I can do is get the interface, run the function ShowWindow() which displays my dialog as a modal dialog. I wanted my dialog to invoke a function in the client app when the user clicked a button, but since I don't have an interface or any COM object whatsoever for my dialog I can't. I tried to do it by creating an interface to my Simple Object in my code for clicking the button on the dialog. But, that doesn't work because I don't have the same interface that the client Advise()d. So, the event never gets to the client. I'm trying desperatly to find a way to be able to interface with my ATL dialog using COM. Any help would be greatly appreciated.
-
I have created an ATL project, inserted a Simple Object and an ATL Dialog via the ATL Object Wizard. Everything works great except for one thing. I don't have an interface to the Dialog. So, my client app can't interface with my dialog. The only thing I can do is get the interface, run the function ShowWindow() which displays my dialog as a modal dialog. I wanted my dialog to invoke a function in the client app when the user clicked a button, but since I don't have an interface or any COM object whatsoever for my dialog I can't. I tried to do it by creating an interface to my Simple Object in my code for clicking the button on the dialog. But, that doesn't work because I don't have the same interface that the client Advise()d. So, the event never gets to the client. I'm trying desperatly to find a way to be able to interface with my ATL dialog using COM. Any help would be greatly appreciated.
Yes, this can be done. The dialogs you get from the ATL Wizard are just normal dialogs, but are not COM objects. Create a simple object called CMyDialogObject or whatever. Create the dialog, called CMyDialog. Embed an instance of the dialog into the simple object as a member variable, and create wrapper functions on the simple object's interface to expose whichever CDialogImpl methods you need, maybe just a DoModal for a modal dialog, or Create and Destroy for a modeless dialog. In the body of the wrapper methods, just delegate to the contained dialog instance. You will need to use the BEGIN_MSG_MAP macro to handle windows messages, commands, etc. in your dialog class. If your dialog class contained a pointer to your simple object, it could delegate to the Fire_XXX method in the message handlers, which would cause the ATL event to fire. Hope that helps