Solved

Problem with WM_USER message

Posted on 2000-03-09
2
406 Views
Last Modified: 2013-11-20
Hi,

I have a problem with WM_USER message. I have a class CRichListBox, child from CListBox. I overriden method
OnLButtonDown(UINT nFlags, CPoint point) this way:

//RichListBox.h:
#define WM_USER_RICHLISTBOX_LINK      WM_USER+0x1235

//RichListBox.cpp:

void CRichListBox::OnLButtonDown(UINT nFlags, CPoint point) {      
  //do something...
 
  //Send WM_USER message to parent
  GetParent()->SendMessage(WM_USER_RICHLISTBOX_LINK, 0, 0);
}


Dialog class:

//C_MFC_TESTDlg.h:

class C_MFC_TESTDlg : public CDialog
{
//...
  //{{AFX_MSG(C_MFC_TESTDlg)
  //...
  afx_msg void OnLink();
  //}}AFX_MSG
  DECLARE_MESSAGE_MAP()
//...
};


//C_MFC_TESTDlg.cpp:
//...
BEGIN_MESSAGE_MAP(C_MFC_TESTDlg, CDialog)
  //{{AFX_MSG_MAP(C_MFC_TESTDlg)
  //...
  ON_MESSAGE(WM_USER_RICHLISTBOX_LINK, OnLink)
 //}}AFX_MSG_MAP
END_MESSAGE_MAP()

//...

void C_MFC_TESTDlg::OnLink() {
  //...
}

This construction works fine in Debug version (Debug configuration). But in Release vesion I get "This program has performad an illegal operation..." e.g. program crashed.

Someone can tell me why this happens? May be I need to delete message after processing?

regards,
 mahno
0
Comment
Question by:mahno
2 Comments
 
LVL 8

Accepted Solution

by:
VinExpert earned 50 total points
ID: 2600118
Hi,

Change Ur function declaration to

afx_msg void OnLink(WPARAM wParam, LPARAM lParam);

And function as
void C_MFC_TESTDlg::OnLink(WPARAM wParam, LPARAM lParam)
{
            //...
}

Hope this helps.

VinExpert
0
 
LVL 1

Author Comment

by:mahno
ID: 2600359
Thanx
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now