Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Adding message handler to MFC App

4 views
Skip to first unread message

Dave Cullen

unread,
Aug 29, 1999, 3:00:00 AM8/29/99
to
I want to add a custom message handling function to my Dialog app. It will
be called when a data aquisition thread has data ready for display.

Following the MSDN instructions, I've done the following:

1) In my Dialog's header file, I put "afx_msg void OnDataReady();" between
the Wizard defined message declarations and the DECLARE_MESSAGE_MAP()
statement.

2) I #defined "WM_DATAREADYMSG (WM_USER + 100)"

3) In the message map I put "ON_MESSAGE(WM_DATAREADYMSG, OnDataReady)"

4) In the Dialog's .cpp file I made a function " void
CMyDlg::OnDataReady()"

The compiler says:
error C2642: cast to pointer to member must be from related pointer to
member

Whazzat?

TIA
drc


Scott McPhillips

unread,
Aug 29, 1999, 3:00:00 AM8/29/99
to
You've got the function prototype wrong. Its return type and parameters must
match this:

afx_msg LRESULT OnNew(WPARAM wParam, LPARAM lParam);

Dave Cullen

unread,
Aug 30, 1999, 3:00:00 AM8/30/99
to

Scott McPhillips wrote:
>
> You've got the function prototype wrong. Its return type and parameters must
> match this:
>
> afx_msg LRESULT OnNew(WPARAM wParam, LPARAM lParam);


Thanks. What's the recommended return value (zero seems to work, but I
don't want any surprises).

drc

--
Dave Cullen

Real Address: dcullen at prox dot com

Andy Yee

unread,
Aug 30, 1999, 3:00:00 AM8/30/99
to
david_dot_cullen_at_snet_dot_net (Dave Cullen) wrote in
<uYR2bwi8#GA....@cppssbbsa02.microsoft.com>:

>I want to add a custom message handling function to my Dialog app. It will
>be called when a data aquisition thread has data ready for display.
>

>2) I #defined "WM_DATAREADYMSG (WM_USER + 100)"
>

Microsoft now asks that user-defined messages start at WM_APP instead
of WM_USER because some of the new common controls actually use messages
above WM_USER.

See KB article Q86835.

------------------------------------------------------------------------
Andy Yee Corporate E-Mail: See Above
Software Engineer Coporate Web Page: http://www.jasc.com
Jasc Software, Inc. Personal E-Mail: n...@yuck.net
Personal Web Page: http://www.visi.com/~nde

Question authority...and the authorities will question YOU!
------------------------------------------------------------------------

Scott McPhillips

unread,
Aug 30, 1999, 3:00:00 AM8/30/99
to

The general rule for LRESULT (a Win32 rule) is to return 0 if you handle the
message. If you don't the MFC macro might choke or it might just pass it on to
default handlers that never heard of your custom message.

0 new messages