.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 4th, 2002, 08:00 PM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 13
ON_MESSAGE in C++.net

Has anyone managed to get ON_MESSAGE to work in MSVC++ .net? I've noticed lot's of help requests splattered across the web, but it seems no one knows how to make it work, since none of them get replies. Here's the old-fashioned way of doing it, works in MSVC++ 6.0.

In MainFrm.h
Code:
DECLARE_MESSAGE_MAP()
LRESULT OnMyMessage(LPARAM lParam, WPARAM wParam);

In MainFrm.cpp
Code:
#define UWM_MYMESSAGE (WM_USER + 1)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
    ON_MESSAGE(UWM_MYMESSAGE, OnMyMessage)
END_MESSAGE_MAP()

LRESULT CMainFrame::OnMyMessage(LPARAM lParam, WPARAM wParam)
{
    return 0;
}

And the error:
...\MainFrm.cpp(30): error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CMainFrame::* )(LPARAM,WPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'

Why is this a problem now? Evidently, the framework doesn't like messages being handled outside of the CWnd class? It doesn't make sense, since you usually don't modify the CWnd class. CMainFrame is inherits from CWnd, so I don't see how the cast should be causing a problem. I've looked up the docs on c2440, but frankly, it's beyond me how that applies to MFC, since I'm not really familiar with the bowels of the MFC code.

How do you get WM_MESSAGE to work in c++.net?

Reply With Quote
  #2  
Old August 5th, 2002, 12:41 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,966 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 52 m 24 sec
Reputation Power: 189
i´m no c++ pro, but from my view:
CMainFrame should be a descendant of CWin, is it? so the declaration should be valid.

oooops, you switched LPARAM and WPARAM
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Reply With Quote
  #3  
Old August 5th, 2002, 02:21 AM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 13
Wow, aren't I the fool? I knew it was something trivial. Hehehe...weeeeee!

I guess it's a good thing that the message map macros now catch bad prototypes, they never used to. Handy.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > ON_MESSAGE in C++.net

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap