Solved

RegisterWindowMessage in MFC

Posted on 1998-05-21
2
1,052 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

746 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

14 Experts available now in Live!

Get 1:1 Help Now