News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

GetMessage Question

Started by Rainstorm, April 17, 2007, 05:20:45 PM

Previous topic - Next topic

Rainstorm

This from the windows SDK..all quotes are from the 'About Messages and Message Queues '...section.
QuoteThe GetMessage function retrieves a message from the calling thread's message queue. The function dispatches incoming sent messages until a posted message is available for retrieval

what does 'The function dispatches incoming sent messages' ...mean ?

there is already  a seperate functon DispatchMessage for dispatching them to the WndProc, right ?
============================

Have another question.
From the SDK..
QuoteThe system posts a message to a thread's message queue by filling an MSG structure and then copying it to the message queue.

then a few lines lower..
QuoteDispatchMessage takes a pointer to MSG that was filled by a previous call to the GetMessage or PeekMessage function.

I can't understand it properly, In one place it says the MSG structure is filled by the system & in the other place it says the MSG structure is filled by the previous call to GetMessage. the two statements seem contradictory.

thanks.

hutch--

Rainstorm,

You can safely assume that for every message that is sent to a Window that the OS has filled out a MSG structure with the appropriate information for that message.

GetMessage() "polls" the message queue but is designed so that if no message is waiting, it does not return until one IS available.

TranslateMessage() is mainly for keyboard messages that you can process in a normal message loop and DispatchMessage() points the message from the message loop to the WndProc callback where messages are normally processed for the Window that owns the message.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Rainstorm

hutch,
     thanks for the reply.

tenkey

There are two message types: those "sent" by the various SendMessage APIs, and those "posted" by PostMessage or PostThreadMessage.

GetMessage calls the appropriate window procedure directly for "sent" messages. Because GetMessage doesn't return when it encounters those messages, "sent" messages do not get filtered by TranslateMessage, IsDialogMessage, or any other filtering functions you put in the message loop.

"Posted" messages include keyboard messages, mouse messages, and WM_QUIT messages. GetMessage returns so that you can filter them before sending them to a window procedure. Also, PostThreadMessage creates messages that don't have a window destination. A return from GetMessage (or PeekMessage) is the only way you can access such "thread" messages.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8