Click here to Skip to main content
15,890,690 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Mapped Drives Pin
Bram van Kampen28-Nov-09 12:54
Bram van Kampen28-Nov-09 12:54 
GeneralRe: Mapped Drives Pin
Garth J Lancaster28-Nov-09 13:23
professionalGarth J Lancaster28-Nov-09 13:23 
GeneralRe: Mapped Drives Pin
Bram van Kampen28-Nov-09 14:27
Bram van Kampen28-Nov-09 14:27 
GeneralRe: Mapped Drives Pin
Garth J Lancaster28-Nov-09 14:35
professionalGarth J Lancaster28-Nov-09 14:35 
QuestionOverlap Message on WM_TIMER Pin
Max++26-Nov-09 15:01
Max++26-Nov-09 15:01 
AnswerRe: Overlap Message on WM_TIMER Pin
«_Superman_»26-Nov-09 16:07
professional«_Superman_»26-Nov-09 16:07 
GeneralRe: Overlap Message on WM_TIMER Pin
Max++26-Nov-09 16:20
Max++26-Nov-09 16:20 
GeneralRe: Overlap Message on WM_TIMER Pin
JohnCz26-Nov-09 19:57
JohnCz26-Nov-09 19:57 
There are certain rules involved:
1. Main window procedure can process only one message at the time.
2. WM_TIMER message is posted to a thread’s queue.
3. Messages posted to the queue are retrieved and removed in a main message loop by GetMessage. There is always one global message loop per process. Local message loops can be created but that is not a case here and it does not change this set of rules.
4. Retrieved messages are delivered to a window procedure by DispatchMessage call.
5. When message is processed, system posted messages are not delivered to a message queue, since the thread is blocked.

Let’s assume you register timer calling SetTimer. After time elapses, system posts the WM_TIMER message to a queue.
Message is then removed and window procedure or callback is called.
If timer message is processed for a time much longer that time interval used to register timer, thread id blocked and no messages are added to a queue.
If processing time is very long, it will render application unresponsive.
After processing is done, queue receives all new messages that are posted by the system.

WM_MOUSEMOVE message as other mouse messages are also posted to the queue, hence if thread is blocked by long processing of any message window will loose WM_MOUSEMOVE, resuming receiving after processing is done.

Timer is not precise. It has low priority and GetMessage can retrieve other messages first before WM_TIMER is retrieved; it is really at the bottom of the food chain.

There is also a set of messages that are delivered by SendMessage directly to a window procedure without being posted.
Considering this and low priority of the WM_TIMER it should not be used when timing is crucial. If that is a case, use another thread to handle such a case.

JohnCz
MS C++ MVP

GeneralRe: Overlap Message on WM_TIMER Pin
Max++27-Nov-09 1:50
Max++27-Nov-09 1:50 
AnswerRe: Overlap Message on WM_TIMER Pin
KarstenK26-Nov-09 23:28
mveKarstenK26-Nov-09 23:28 
AnswerRe: Overlap Message on WM_TIMER Pin
JohnCz27-Nov-09 6:14
JohnCz27-Nov-09 6:14 
GeneralRe: Overlap Message on WM_TIMER Pin
Max++27-Nov-09 14:41
Max++27-Nov-09 14:41 
AnswerRe: Overlap Message on WM_TIMER Pin
JohnCz27-Nov-09 20:14
JohnCz27-Nov-09 20:14 
GeneralRe: Overlap Message on WM_TIMER Pin
KarstenK29-Nov-09 20:36
mveKarstenK29-Nov-09 20:36 
Questionprolog help Pin
golisarmi26-Nov-09 10:18
golisarmi26-Nov-09 10:18 
AnswerRe: prolog help Pin
CPallini26-Nov-09 20:41
mveCPallini26-Nov-09 20:41 
GeneralRe: prolog help Pin
Michael Schubert27-Nov-09 0:11
Michael Schubert27-Nov-09 0:11 
GeneralRe: prolog help Pin
Richard MacCutchan27-Nov-09 1:01
mveRichard MacCutchan27-Nov-09 1:01 
GeneralRe: prolog help Pin
Michael Schubert27-Nov-09 2:30
Michael Schubert27-Nov-09 2:30 
GeneralRe: prolog help Pin
Richard MacCutchan27-Nov-09 2:57
mveRichard MacCutchan27-Nov-09 2:57 
GeneralRe: prolog help Pin
CPallini27-Nov-09 4:48
mveCPallini27-Nov-09 4:48 
AnswerRe: prolog help Pin
Maximilien27-Nov-09 1:28
Maximilien27-Nov-09 1:28 
QuestionProcess ID from HWND [solved] Pin
PJ Arends26-Nov-09 7:30
professionalPJ Arends26-Nov-09 7:30 
AnswerRe: Process ID from HWND Pin
«_Superman_»26-Nov-09 8:46
professional«_Superman_»26-Nov-09 8:46 
GeneralRe: Process ID from HWND Pin
PJ Arends26-Nov-09 9:17
professionalPJ Arends26-Nov-09 9:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.