Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
349 views
in Technique[技术] by (71.8m points)

c - Determine priority of a window message

Is there any way to programmatically check the priority of a window messages in its message queue?

For example: Some of window messages, WM_PAINT and WM_TIMER are known have the lowest priority and be placed after messages with highest priority.

I'm looking for something by which you can confirm that which one of two messages will have the lowest or highest priority or which message will be sent first or last?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

That's just not how it works, Windows messages don't have a priority attached. It is mostly determined by how the message is generated. A message loop dispatches messages in this order:

  • first any messages generated with SendMessage() are dispatched in the order in which the calls were made
  • next, any messages generated with PostMessage() and stored in the message queue, in queue order
  • next, any messages that are synthesized from the window state. WM_TIMER, WM_PAINT and WM_MOUSEMOVE fit this category.

The 'synthesized from the window state' clause is what makes WM_PAINT and WM_TIMER appear to have a low priority. And why moving the mouse rapidly doesn't flood the message queue with mouse messages. That is however not exclusive, you can for example call UpdateWindow() to force a WM_PAINT message to be sent, making it being dispatched with a 'high priority'.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...