PostMessage() problems
-
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)
-
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)
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 theOnToggle()
method?
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
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)
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.