Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to send message to CWinApp derived object

919 views
Skip to first unread message

David Lowndes

unread,
May 26, 2000, 3:00:00 AM5/26/00
to
>could someone tell how to send custom message to CWinApp derived objec. I
>tied this:

Tomas,

Non window classes such as the CWinApp object can only handle special
categories of messages that MFC routes to non-window classes.

You can post user defined messages to windows - such as the main frame
window.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.

Tomas Butkus

unread,
May 27, 2000, 3:00:00 AM5/27/00
to
Hi,

could someone tell how to send custom message to CWinApp derived objec. I
tied this:

#define MYMSG (WM_APP + 1)
...
ON_MESSAGE(MYMSG, DoSomething)
...
SendMessage(MYMSG);

This not works- object didn't handle this message.
Should i use ON_THREAD_MESSAGE and PostThreadMessage(...) instead?

Thans in advance


--
Tomas Butkus


David Wilkinson

unread,
May 27, 2000, 3:00:00 AM5/27/00
to
Tomas:

I have not done this, but I think that all posted messages to your
application can be trapped in CWinApp::PreTranslateMessage(). Return
TRUE if you handle the message or call the base class if you do not. You
can post the message itself to the main window.

Or you can send/post a "fake command message" using WM_COMMAND and use
WPARAM/LPARAM to identify the message.

You can also use PostThreadMessage(), but these messages can be lost if
a modal dialog or message box is opened before the message is processed.

Actually I think it is strange that MFC did not implement a
CWinApp::SendMessage/PostMessage capability.

But if you want to send, rather than post, the message, why not just
call a function in your CWinApp derived class?

HTH,

David Wilkinson

Ajay Kalra

unread,
May 27, 2000, 3:00:00 AM5/27/00
to
Use PostThreadMessage to post a message to CWinApp.

--
Ajay Kalra
ajay...@yahoo.com
Microsoft VC++/MFC MVP

Note: Please post all replies to newsgroup only.

Tomas Butkus <tom...@nomagiclt.com> wrote in message
news:O1FIW#1x$GA.277@cppssbbsa04...

0 new messages