Solved

RegisterWindowMessage in MFC

Posted on 1998-05-21
2
1,076 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ShiftLeft challenge 21 86
abstract class with all non abstract mentods 6 80
Sed question 2 103
Problem to App 4 99
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

820 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