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. RegisterWindowsMessage

RegisterWindowsMessage

Scheduled Pinned Locked Moved C / C++ / MFC
comdebugginghelpquestion
3 Posts 3 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.
  • U Offline
    U Offline
    User 3512
    wrote on last edited by
    #1

    I’ve been reading your submission on registerwindowmessage at the codeguru.com web site. Your information in addition to some other sources, sure seems simple enough. The only problem is I just can not get it to work. This is what I have done. Can you suggest where I am going wrong? Maybe it is the way I send the message? I want to send a message from one dialog-based exe to another. Both exe’s have this message defined. #define TESTMSG "TESTMSG" Both exe’s get the message id like this, and the debugger shows both get the same value. int gnStartMsg = RegisterWindowMessage(TESTMSG); The sending exe then sends a message like this. SendMessage(gnStartMsg, 0, 0); The receiving exe has this message map and member function. BEGIN_MESSAGE_MAP(CRegToDlg, CDialog) //{{AFX_MSG_MAP(CRegToDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_REGISTERED_MESSAGE(gnStartMsg, OnMsgTest) void CRegToDlg::OnMsgTest() { AfxMessageBox("I made it"); } The messagebox is never displayed. PMCGA61201@AOL.COM Thank you.

    S M 2 Replies Last reply
    0
    • U User 3512

      I’ve been reading your submission on registerwindowmessage at the codeguru.com web site. Your information in addition to some other sources, sure seems simple enough. The only problem is I just can not get it to work. This is what I have done. Can you suggest where I am going wrong? Maybe it is the way I send the message? I want to send a message from one dialog-based exe to another. Both exe’s have this message defined. #define TESTMSG "TESTMSG" Both exe’s get the message id like this, and the debugger shows both get the same value. int gnStartMsg = RegisterWindowMessage(TESTMSG); The sending exe then sends a message like this. SendMessage(gnStartMsg, 0, 0); The receiving exe has this message map and member function. BEGIN_MESSAGE_MAP(CRegToDlg, CDialog) //{{AFX_MSG_MAP(CRegToDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_REGISTERED_MESSAGE(gnStartMsg, OnMsgTest) void CRegToDlg::OnMsgTest() { AfxMessageBox("I made it"); } The messagebox is never displayed. PMCGA61201@AOL.COM Thank you.

      S Offline
      S Offline
      Sadhu
      wrote on last edited by
      #2

      Check thar you made entry in .h file. afx_msg LRESULT yourfunction(WPARAM wParam,LPARAM lParam); and your .cpp file static int gnStartMsg=....... LRESULT yourclass::yourfunction(WPARAM wParam,LPARAM lParam) hope this helps; sadhu ================== The original message was: I’ve been reading your submission on registerwindowmessage at the codeguru.com web site.

      Your information in addition to some other sources, sure seems simple enough. The only problem is I just can not get it to work.

      This is what I have done. Can you suggest where I am going wrong? Maybe it is the way I send the message?

      I want to send a message from one dialog-based exe to another.

      Both exe’s have this message defined.

      #define TESTMSG "TESTMSG"

      Both exe’s get the message id like this, and the debugger shows both get the same value.

      int gnStartMsg = RegisterWindowMessage(TESTMSG);

      The sending exe then sends a message like this.

      SendMessage(gnStartMsg, 0, 0);

      The receiving exe has this message map and member function.

      BEGIN_MESSAGE_MAP(CRegToDlg, CDialog)
      //{{AFX_MSG_MAP(CRegToDlg)
      ON_WM_SYSCOMMAND()
      ON_WM_PAINT()
      ON_WM_QUERYDRAGICON()
      //}}AFX_MSG_MAP
      ON_REGISTERED_MESSAGE(gnStartMsg, OnMsgTest)

      void CRegToDlg::OnMsgTest()
      {
      AfxMessageBox("I made it");
      }

      The messagebox is never displayed.
      PMCGA61201@AOL.COM
      Thank you.

      1 Reply Last reply
      0
      • U User 3512

        I’ve been reading your submission on registerwindowmessage at the codeguru.com web site. Your information in addition to some other sources, sure seems simple enough. The only problem is I just can not get it to work. This is what I have done. Can you suggest where I am going wrong? Maybe it is the way I send the message? I want to send a message from one dialog-based exe to another. Both exe’s have this message defined. #define TESTMSG "TESTMSG" Both exe’s get the message id like this, and the debugger shows both get the same value. int gnStartMsg = RegisterWindowMessage(TESTMSG); The sending exe then sends a message like this. SendMessage(gnStartMsg, 0, 0); The receiving exe has this message map and member function. BEGIN_MESSAGE_MAP(CRegToDlg, CDialog) //{{AFX_MSG_MAP(CRegToDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_REGISTERED_MESSAGE(gnStartMsg, OnMsgTest) void CRegToDlg::OnMsgTest() { AfxMessageBox("I made it"); } The messagebox is never displayed. PMCGA61201@AOL.COM Thank you.

        M Offline
        M Offline
        Mike Dunn
        wrote on last edited by
        #3

        The problem is this line: SendMessage(gnStartMsg, 0, 0); This sends the message right back to the CDialog that this code is in. You want to do: ::SendMessage ( hwndOtherDlg, gnStartMsg, 0, 0 ); where hwndOtherDlg is the HWND of the receiving dialog. Or, if you have a CWnd* to it, you can do: pOtherDlg->SendMessage ( gnStartMsg, 0, 0 );

        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