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. MFC: Problem using CWnd::SendMessage

MFC: Problem using CWnd::SendMessage

Scheduled Pinned Locked Moved C / C++ / MFC
c++comhelptutoriallearning
3 Posts 2 Posters 1 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.
  • D Offline
    D Offline
    Davex_
    wrote on last edited by
    #1

    Hello all, I'm presently learning how to use my own message handlers in my MFC application. I read this article: Windows Message Handling - Part 2 here: http://www.codeproject.com/dialog/messagehandling2.asp. I have a problem with one line of code; when I need to get the CWnd* to send the message. In my case, I want to send the message to my main view based on CFormView when I'm in another dialog or class. Here's how I was trying to do it: pMyMainView = CWnd::FindWindow(_T("CMyMainView"),NULL); pMyMainView->SendMessage(WM_MYMESSAGE,0,0); But FindWindow don't find my CMyMainView, so I can't send the message. I tried "this->SendMessage(WM_MYMESSAGE,0,0);" in my CMyMainView.cpp to verify my message handler and it's working. It must be so simple! But I started coding in C++ and MFC only 1 month ago. :-) Thanks, Dave

    RaviBeeR 1 Reply Last reply
    0
    • D Davex_

      Hello all, I'm presently learning how to use my own message handlers in my MFC application. I read this article: Windows Message Handling - Part 2 here: http://www.codeproject.com/dialog/messagehandling2.asp. I have a problem with one line of code; when I need to get the CWnd* to send the message. In my case, I want to send the message to my main view based on CFormView when I'm in another dialog or class. Here's how I was trying to do it: pMyMainView = CWnd::FindWindow(_T("CMyMainView"),NULL); pMyMainView->SendMessage(WM_MYMESSAGE,0,0); But FindWindow don't find my CMyMainView, so I can't send the message. I tried "this->SendMessage(WM_MYMESSAGE,0,0);" in my CMyMainView.cpp to verify my message handler and it's working. It must be so simple! But I started coding in C++ and MFC only 1 month ago. :-) Thanks, Dave

      RaviBeeR Offline
      RaviBeeR Offline
      RaviBee
      wrote on last edited by
      #2

      I'm not sure what you mean by "my main view". To get the application's main window, use AfxGetMainWnd(). To get the dialog's parent window, use GetParent(). Hope this helps. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      D 1 Reply Last reply
      0
      • RaviBeeR RaviBee

        I'm not sure what you mean by "my main view". To get the application's main window, use AfxGetMainWnd(). To get the dialog's parent window, use GetParent(). Hope this helps. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

        D Offline
        D Offline
        Davex_
        wrote on last edited by
        #3

        Thank You Ravi, I knew it was simple, but...! hehe It worked with GetParent();

        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