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. PostMessage() problems

PostMessage() problems

Scheduled Pinned Locked Moved C / C++ / MFC
c++comdebugginghelpannouncement
3 Posts 3 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.
  • S Offline
    S Offline
    Sid_smily
    wrote on last edited by
    #1

    Hi, i have inherited a class from CEdit, and want to send my application a user defined message from this class. i have used PostMessage function for that reason from my class's LBUTTONDOWN message. The message is captured by my window (a dialog box that has an edit box linked by a variable of my class) and works well while i work in Debug configuration, but causes an unhandled exception in Release Configuration:confused:. I would be obliged if any one can help me.. -------- THE CODE SAMPLE: -------- Dev. Platform : VC++ 6.0 OS: Windows 2000 Professional //class definition class CMyClass : public CEdit { ... } Void CMyClass::OnLButtonDown(UINT nFlags, CPoint point) { // my code... .... CEdit::OnLButtonDown(nFlags, point); //m_hParWnd is the handle of parent dialog claas ::PostMessage(m_hParWnd, TOGGLE, 0, 0); } /*My applications main dialog with a member variable of CMyClass associated with an edit box*/ .. ON_MESSAGE(TOGGLE, OnToggle) ... CMyAppDlg::OnToggle() { .... } Kind Regards Siddique Ahmed Senior Software Engineer Telelogix Software (www.telelogix.com)

    D A 2 Replies Last reply
    0
    • S Sid_smily

      Hi, i have inherited a class from CEdit, and want to send my application a user defined message from this class. i have used PostMessage function for that reason from my class's LBUTTONDOWN message. The message is captured by my window (a dialog box that has an edit box linked by a variable of my class) and works well while i work in Debug configuration, but causes an unhandled exception in Release Configuration:confused:. I would be obliged if any one can help me.. -------- THE CODE SAMPLE: -------- Dev. Platform : VC++ 6.0 OS: Windows 2000 Professional //class definition class CMyClass : public CEdit { ... } Void CMyClass::OnLButtonDown(UINT nFlags, CPoint point) { // my code... .... CEdit::OnLButtonDown(nFlags, point); //m_hParWnd is the handle of parent dialog claas ::PostMessage(m_hParWnd, TOGGLE, 0, 0); } /*My applications main dialog with a member variable of CMyClass associated with an edit box*/ .. ON_MESSAGE(TOGGLE, OnToggle) ... CMyAppDlg::OnToggle() { .... } Kind Regards Siddique Ahmed Senior Software Engineer Telelogix Software (www.telelogix.com)

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Sid_smily wrote: ::PostMessage(m_hParWnd, TOGGLE, 0, 0); Is m_hParWnd non-NULL? If you comment out this statement, does the UE still occur? Does anything special happen within the OnToggle() method?


      Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

      1 Reply Last reply
      0
      • S Sid_smily

        Hi, i have inherited a class from CEdit, and want to send my application a user defined message from this class. i have used PostMessage function for that reason from my class's LBUTTONDOWN message. The message is captured by my window (a dialog box that has an edit box linked by a variable of my class) and works well while i work in Debug configuration, but causes an unhandled exception in Release Configuration:confused:. I would be obliged if any one can help me.. -------- THE CODE SAMPLE: -------- Dev. Platform : VC++ 6.0 OS: Windows 2000 Professional //class definition class CMyClass : public CEdit { ... } Void CMyClass::OnLButtonDown(UINT nFlags, CPoint point) { // my code... .... CEdit::OnLButtonDown(nFlags, point); //m_hParWnd is the handle of parent dialog claas ::PostMessage(m_hParWnd, TOGGLE, 0, 0); } /*My applications main dialog with a member variable of CMyClass associated with an edit box*/ .. ON_MESSAGE(TOGGLE, OnToggle) ... CMyAppDlg::OnToggle() { .... } Kind Regards Siddique Ahmed Senior Software Engineer Telelogix Software (www.telelogix.com)

        A Offline
        A Offline
        Abin
        wrote on last edited by
        #3

        You are defining an incorrect handling function in your CMyAppDlg, the right way to do so is: // in MyAppDlg.h class CMyAppDlg : public CDialog { // ... ... afx_msg LRESULT OnToggle(WPARAM wParam, LPARAM lParam); // ... ... } // in MyAppDlg.cpp ON_MESSAGE(TOGGLE, OnToggle) LRESULT CMyAppDlg::OnToggle(WPARAM wParam, LPARAM lParam) { // ... ... return (LRESULT)0; } This will work fine.

        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