SendMessage is to wait until the message was accepted, PostMessage just
queues the message into the message-queue?
As I understand it, SendMessage calls the window procedure directly.
--
Ben Newsam
SendMessage waits until the message was processed, that's a different thing.
PostMessage send the message, places it in a queue. This message will be
processed when the time is right.
Ciao
--
TiTi (Tom Tempelaere)
Upsilon S.A. - Financial and Computer Engineering
Luxembourg
"All your base are belong to us!" - Cats/Zero Wing
Why do you want to process the message in PreTranslateMessage? Just put a
message handler to your Dialog class with the ON_MESSAGE macro.
Cheers
Abbas Cakmak
Yes, SendMessage sends the message and calls the handler directly; PostMessage queues the
message for later processing. A thread should only use PostMessage.
joe
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm
On a different message thread in probably a different newsgroup
someone made a good additional observation about SendMessage
versus PostMessage.
SendMessage will be processed in the calling thread's context.
PostMessage will be processed in the receiving thread's context.
An important distinction.
Rufus
I don't think so. Message handlers *always* execute in the thread that's
running the message loop. From the SendMessage doc's Remarks section (*
emphasis mine):
<begin quote>
If the specified window was created by the calling thread, the window
procedure is called immediately as a subroutine. If the specified window was
created by a different thread, the system *switches to that thread* and
calls the appropriate window procedure. Messages sent between threads are
processed only when the receiving thread executes message retrieval code.
The sending thread is blocked until the receiving thread processes the
message.
<end quote>
That's the beauty of message loops. You're guaranteed that you're running in
the thread you're supposed to be.
--
Jay
>On a different message thread in probably a different newsgroup
>someone made a good additional observation about SendMessage
>versus PostMessage.
>
>SendMessage will be processed in the calling thread's context.
>
>PostMessage will be processed in the receiving thread's context.
>
>An important distinction.
It sounds like you're talking about inter-thread messages, and
inter-thread SendMessages are processed by the receiving thread.
Besides message queue usage, the important distinction between
SendMessage and PostMessage is that SendMessage is synchronous, even
inter-thread SendMessage. Thus, the initiator of an inter-thread
SendMessage blocks until the target thread enters a receptive state
and fully processes the message. This is explained further in MSDN.
(An inter-thread SendMessage often consists of sending a message to a
window created by another thread; the thread which created a window is
the only thread which can process that window's messages.)
--
Doug Harrison [VC++ MVP]
Eluent Software, LLC
http://www.eluent.com
Tools for Visual C++ and Windows
Well, that's what I thought in the first place!
It didn't make sense to me that your message handler would have to concern
itself as to whether the message had been Post'ed or Sent to it!
Now I have to go back to that font of misinformation!
(It would certainly be easy enough to test by doing a GetCurrentThreadID
within the message handler...)
Rufus
if true, but it's not true!!
>
> It sounds like you're talking about inter-thread messages, and
> inter-thread SendMessages are processed by the receiving thread.
Thanks Doug,
Jay has also pointed this out and I gave a response then.
The discussion question was "VC++ has something like Timer control of VB??"
Rufus
Thank you
POSITION pos = this->GetFirstViewPosition();
while(pos)
{
CView *pView = this->GetNextView( &pos );
if(pView->IsKindOf(RUNTIME_CLASS(CYourView)))
{
CYourView *pMyView = (CYourView *)pView;
// Now you get to your vector variable in the view
}
}
There's probably a better way to do this, so I welcome suggestions as well.
"Tron23" <tro...@qwest.net> wrote in message
news:3C16E24...@qwest.net...