Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Sending messages between a Qt application and an MFC application
QtWS25 Last Chance

Sending messages between a Qt application and an MFC application

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 4.4k Views
  • 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.
  • musimbateM Offline
    musimbateM Offline
    musimbate
    wrote on last edited by
    #1

    Hi,
    I have two applications one is MFC(and I only have the executable ,but know that it is sending messages when some buttons are pushed) and the other is done using Qt.The one in MFC using something like this to send messages:
    @

    CString strDataToSend = _T( "Hello" );
    HWND hWndReceived;
    COPYDATASTRUCT cpd;
    cpd.dwData = 0;
    cpd.cbData = strDataToSend.GetLength();
    cpd.lpData = (void*)strDataToSend.GetBuffer(cpd.cbData);
    SendMessage( hWndReceived, WM_COPYDATA, 0, (LPARAM) & cpd );
    strDataToSend.ReleaseBuffer();

    @

    I need to receive those messages in my Qt application and take some appropriate actions.
    Is there a way Qt makes this easy to implement?
    Thanks.

    Why join the navy if you can be a pirate?-Steve Jobs

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dasun
      wrote on last edited by
      #2

      What are you trying to do? If you want to communicate between applications you might need to look at some IPC(Inter process communication) methods. try this link "http://qt-project.org/doc/qt-5.0/qtdoc/ipc.html":http://qt-project.org/doc/qt-5.0/qtdoc/ipc.html

      1 Reply Last reply
      0
      • N Offline
        N Offline
        NicuPopescu
        wrote on last edited by
        #3

        HWND hWndReceived must be a valid handle of an existing window object

        try to find the qt window with "FindWindow":http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499(v=vs.85).aspx ... you can use Spy++ to look at window class name to be found

        anyway if you have access to the code of both apps you should consider other way for IPC

        1 Reply Last reply
        0
        • musimbateM Offline
          musimbateM Offline
          musimbate
          wrote on last edited by
          #4

          Thanks guys,
          I found that sockets are an easy way to get this done quickly as the project is tight on time.

          Thanks again.

          Why join the navy if you can be a pirate?-Steve Jobs

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved