Skip to content

SetTimer(NULL,NULL,<timeout>,NULL) doesn't behave correctly. #1183

@chentiangemalc

Description

@chentiangemalc

When a hWnd is not specified to set timer, and it is checked in a peekmessage loop

  1. WM_TIMER seems to fire instantly, instead of after the time period has expired as per on Windows XP with NTVDM. i.e should be after 10 seconds in this example code.
  2. WM_TIMER doesn't fire again after clicking OK on message box in this test app, unless hit ALT+TAB. On Windows XP it will fire again on timer without needing to do this.

If a hwnd is specified, the WM_TIMER is correctly sent to the wndproc handler as expected.

Example code:

   SetTimer(NULL,NULL,10000,NULL);
   BOOL fRetVal = TRUE;
   
     // classic Win3.1 peek message loop   

     for(;;)
     {

        while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {              
        
           if (msg.message == WM_TIMER)
           {   
           	MessageBox(hwnd,"Hit Timer","Timer!!",MB_OK);   
           }
           
           if (msg.message == WM_QUIT)
              return TRUE;

           TranslateMessage(&msg);
           DispatchMessage(&msg);
        }
        
        // check if need to do background processing, otherwise call WaitMessage
        WaitMessage(); 

     }

Environment (please complete the following information):
Windows 11 21H2 22000.739

Trace and sample program (MSVC 1.52 exe+source) attached
MSGTST.zip
trace.txt
.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions