Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Message routing

Posted on 1998-10-16
2
Medium Priority
?
177 Views
Last Modified: 2013-11-20
Hi,
I want rout a message to a CCmdTarget derived class.
I tried something like that (in the Main-App):

BOOL CMyApp::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
   if ((m_pMyCmdDerivedClass != NULL)&& m_pMessageController->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
   return TRUE;

   return CWinApp::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

m_pMyCmdDerivedClass is a pointer to my class (derived from CCmdTarget).
This works fine for commands in the menu (e.g. file open).
But if I post a message to my Main-App thread like
#define WM_MY_MESSAGE WM_USER + 1

::PostThreadMessage( AfxGetApp( )->m_nThreadID, WM_MY_MESSAGE, 0, 0 );

the message is posted to the main thread object (I can catch it with ON_MESSAGE(WM_MY_MESSAGE, MyMethod)    )
BUT IT IS NOT ROUTED TO THE m_pMyCmdDerivedClass OBJECT!!!!!!!!!
any ideas?
dib
0
Comment
Question by:dib
[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
 

Author Comment

by:dib
ID: 1323438
Edited text of question
0
 
LVL 3

Accepted Solution

by:
plaroche earned 800 total points
ID: 1323439
As you can see in the name of the handler "OnCmdMsg" this is for commande messages, namely WM_COMMAND.

What you might want to do is define new WM_COMMAND messages and post them to your app, they will be routed correctly and be catchable by any object in the food chain.

You can check the doc for a command message, but BEWARE that command message notifications might interfere with your own.

Something like:

pWnd->PostMessage(WM_COMMAND, (WPARAM)MAKELONG(0,USER_DEFINED_NOTIF), (LPARAM)hWnd);


0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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 …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

597 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