Solved

RegisterWindowMessage in MFC

Posted on 1998-05-21
2
1,060 Views
Last Modified: 2013-11-20
Hi,
I am using functions from a 3d mouse (Pegasus FreeD)DLL, and the example code (which des work) is written in ordinary c++ windows
format (WndProc, WinMain etc).  I am trying to convert it to work in an MFC environment.
The application opens the DLL with the app window handle, to which messages form the dll are sent when
new information is available from the input device.
The .h file for the dll has the following definition:

#define FREEDMessageIdName "3D_FREED_New_Info"
FREED_info FREED_Info;         // structure containing data for the 3d input device
static WORD WM_FREED_NewInfo=0;

The application code, after opening the dll, calls RegisterWindowMessage, in the WM_CREATE section
of the windows message loop:
WM_FREED_NewInfo = RegisterWindowMessage(FREEDMessageIdName);
..

Then each time in the message loop, a WM_FREED_NewInfo message is detected(sent by the dll)
whenever there is new information available.
Fine.
Putting it in MFC, how do I get the message map to work? It doesn't seem to at the moment.
In the ..View constructor, I called the RegisterWindowMessage as above, and in the message map:
ON_MESSAGE(WM_FREED_NewInfo, OnNewInfo)
but it never seems to pick up those messages (if they are in the queue at all).

Thanks for any help
KingPie

0
Comment
Question by:kingpie
2 Comments
 

Accepted Solution

by:
agopal earned 100 total points
ID: 1313751
I think you should use ON_REGISTERED_MESSAGE
also here is the code from 'MSDN Help'

  const UINT     wm_Find = RegisterWindowMessage( FINDMSGSTRING )
BEGIN_MESSAGE_MAP( CMyWnd, CMyParentWndClass )
    //{{AFX_MSG_MAP( CMyWnd )
    ON_REGISTERED_MESSAGE( wm_Find, OnFind )
    // ... Possibly more entries to handle additional messages
    //}}AFX_MSG_MAP
END_MESSAGE_MAP( )
 
 

0
 

Author Comment

by:kingpie
ID: 1313752
Great stuff!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

19 Experts available now in Live!

Get 1:1 Help Now