Re: DDE in MFC
-
Hello all, I am using Visual Studio 2008, and I created a new MDI application. In the setup of the application, I chose a file extension to use. In InitInstance of the class derived from CWinApp, I added this code as the first line of the function:
AfxMessageBox("InitInstance");
Also, in the class derived from CWinApp, I added as the first line of the function OnDDECommand:
AfxMessageBox("OnDDECommand");
When I run this program from the IDE, everything appears to be fine. However, when I run this from Windows explorer and double-click on the appropriate file (a file with the extension my program uses), I see the message: "Windows cannot find 'E:\Mikea Documents\mdi41.mdi4'. Make sure you typed the name correctly, and then try again. To search for a file, click the Start button, and then click Search." I also saw the InitInstance message as was expected, but I didn't see any GUI, nor did I see any OnDDECommand message. The application remains open. Now, if I double-click on the file again, I see the OnDDECommand message and the GUI, but I didn't see the InitInstance message. The application now closes. I have looked at different places on the internet to try to figure out why this is happening, but I haven't gotten anywhere. Does anyone have any ideas?
Regards, Mike
-
Hello all, I am using Visual Studio 2008, and I created a new MDI application. In the setup of the application, I chose a file extension to use. In InitInstance of the class derived from CWinApp, I added this code as the first line of the function:
AfxMessageBox("InitInstance");
Also, in the class derived from CWinApp, I added as the first line of the function OnDDECommand:
AfxMessageBox("OnDDECommand");
When I run this program from the IDE, everything appears to be fine. However, when I run this from Windows explorer and double-click on the appropriate file (a file with the extension my program uses), I see the message: "Windows cannot find 'E:\Mikea Documents\mdi41.mdi4'. Make sure you typed the name correctly, and then try again. To search for a file, click the Start button, and then click Search." I also saw the InitInstance message as was expected, but I didn't see any GUI, nor did I see any OnDDECommand message. The application remains open. Now, if I double-click on the file again, I see the OnDDECommand message and the GUI, but I didn't see the InitInstance message. The application now closes. I have looked at different places on the internet to try to figure out why this is happening, but I haven't gotten anywhere. Does anyone have any ideas?
Regards, Mike
My best guess is that of the Messagebox you have put in the InitInstance is behind this behaviour. The first time you double click on your file "mdi41.mdi4", your .exe application gets launched, however it is not getting intitalized correctly, untill you dismiss the MessageBox->"InitInstance" by clicking OK. Once this happens, even though the document did not get loaded correctly, the Application may still be running (verify this using taskmanager). And next time you double click on the document again, the above mentioned running instance get the notification and loads the document correctly.
-Suhredayan
-
My best guess is that of the Messagebox you have put in the InitInstance is behind this behaviour. The first time you double click on your file "mdi41.mdi4", your .exe application gets launched, however it is not getting intitalized correctly, untill you dismiss the MessageBox->"InitInstance" by clicking OK. Once this happens, even though the document did not get loaded correctly, the Application may still be running (verify this using taskmanager). And next time you double click on the document again, the above mentioned running instance get the notification and loads the document correctly.
-Suhredayan
Hello, I checked the Task Manager, and sure enough, the program was still running. However, I want the program to show the InitInstance message and run the GUI regardless of whether the program is run from the IDE or the program is run after double-clicking the mdi4 file. Furthermore, I don't want to see the "Windows cannot find 'E:\MikeA Documents\mdi41.mdi4'. Make sure you typed the name correctly, and then try again. To search for a file, click the Start button, and then click Search." message.
Regards, Mike
-
Hello, I checked the Task Manager, and sure enough, the program was still running. However, I want the program to show the InitInstance message and run the GUI regardless of whether the program is run from the IDE or the program is run after double-clicking the mdi4 file. Furthermore, I don't want to see the "Windows cannot find 'E:\MikeA Documents\mdi41.mdi4'. Make sure you typed the name correctly, and then try again. To search for a file, click the Start button, and then click Search." message.
Regards, Mike
Michael Adamus wrote:
I want the program to show the InitInstance message
Try to show the message using modelelss dialogbox, or spawn a thread from InitInstance to display the message box.
Michael Adamus wrote:
Furthermore, I don't want to see the "Windows cannot find 'E:\MikeA Documents\mdi41.mdi4'. Make sure you typed the name correctly, and then try again. To search for a file, click the Start button, and then click Search." message.
This seems to be a bug within windows, it should have displayed a better error message, like for eg: "The DDE transcation failed", however if the actual issue (blocking InitInstance()) is addressed, then you might not face this one anyways.
-Suhredayan