Re: The basics of Windows' messages




"Ney André de Mello Zunino" <zunino@xxxxxxxxxxx> a écrit dans le message de
news: u8M4dKSiGHA.1600@xxxxxxxxxxxxxxxxxxxxxxx
Hello.

It's been more than 6 years since I took a look at Petzold's book. I would
like to check just how dusty my comprehension of the basic architecture of
Windows applications is. I will try to depict my current understanding by
writing a series of statements. My main interest, at the moment, is in the
message sending/pumping/dispatching cycle. Any correction or remark will
be appreciated.

There is Windows (the OS) and there are applications. Each application
(more specifically, each thread that creates a window) is given/assigned a
message queue. Windows translates low-level user input (e.g. keyboard or
mouse interruptions, etc.) into system messages and places them at the end
of the respective application's queue.

That's right. Messages can also be posted on the queue :
- By other Windows inside the app. For example, a control notifies it's
parent windows that something has changed in it.
- By other apps (eg, an home-made interprocess communication mechanism).
- By Windows for specific reasons, such as a timer that has expired or a
system-wide setting that has changed.


Up to this point, the thread owning the queue would do nothing else in its
available time slice other than check for messages on its queue (with,
e.g., /GetMessage()/). As soon as it realizes there is a message, the
thread removes it from the queue and dispatches it (calls
/DispatchMessage()/). The code in /DispatchMessage()/ will find out which
window procedure should be called and then invoke it. All this happens in
the context of the thread which initially removed the message from the
queue. As the message processing is over, the thread will resume its queue
watching activity and the whole cycle starts over.

That's right. You should also take into consideration the TranslateMessage
function, which concumes keyboard messages and transform them into
characters messages (eg, the combination of a "A" key-down event followed by
a "A" key-up event is translated into a character "A" message).

Well, I guess that's pretty much the idea I currently have of the basic
workings of Windows. I sincerely wish to have that idea checked and my
understanding improved by the valuable input of more experienced fellows.
Your understanding is correct. How
ever, nowadays, we need less and less to get down to this level of detail.
Many libraries (eg MFC, .NET winforms, etc....) shield developpers from
those low-level details. Anyway, it's always a good idea to have a firm
grasp on them.

Arnaud
MVP - VC


.



Relevant Pages

  • Re: The basics of Windows messages
    ... There is Windows and there are applications. ... end of the respective application's queue. ... understanding improved by the valuable input of more experienced fellows. ... those low-level details. ...
    (microsoft.public.win32.programmer.kernel)
  • RE: Problems Printing After XP Upgrade from 98SE
    ... following steps to clean the printer subsystem completely on the ... Windows NT Fax Monitor ... AppleTalk Printing Devices ... | workstation, but if I do that, I'll have to create the queue and re-share ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: as400 print que on windows 2003
    ... If the firewall doesn't fix your problem, try using RPM Select from ... The culprit may be the Windows Firewall. ... configuring TCP print services on another device (you can use Windows ... and the printer queue name exsists with no special characters. ...
    (comp.sys.ibm.as400.misc)
  • Re: Delaying events for fixed amounts of time.
    ... amount of time after the *FIRST* event with a given key arrives. ... I have anything Windows has to offer. ... Pause for, say, 250ms each time through the loop ... Have a queue of keys, each time a new key arrives, add it to the end ...
    (comp.programming.threads)
  • RE: Problems Printing After XP Upgrade from 98SE
    ... Can you print any local print jobs correctly in the system which ... Does the issue occur on only one Windows XP client or all other Windows ... | all of the jobs from the queue and print a test page from XP, ... |> Use the net.exe command to establish a persistent connection. ...
    (microsoft.public.windowsxp.help_and_support)

Loading