Solved

RegisterWindowMessage in MFC

Posted on 1998-05-21
2
1,087 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
function returning CString in a regular win32 DLL 8 215
List out all word 7 357
Change to event 1 137
unix example issues 18 113
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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…
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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