Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Re: DDE in MFC

Re: DDE in MFC

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiocsharpc++questionworkspace
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mla154
    wrote on last edited by
    #1

    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

    2 1 Reply Last reply
    0
    • M mla154

      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

      2 Offline
      2 Offline
      224917
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • 2 224917

        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

        M Offline
        M Offline
        mla154
        wrote on last edited by
        #3

        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

        2 1 Reply Last reply
        0
        • M mla154

          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

          2 Offline
          2 Offline
          224917
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups