|
-
June 30th, 2011, 12:05 PM
#8
Re: Flooded WndProc
Games like Half-Life 1, Counterstrike I tested on aswell.
You can reproduce the bug simply by making a new standard Win32 Application project in Visual Studio.
Then, make the following changes to the code:
In InitInstance(HINSTANCE hInstance, int nCmdShow), make "HWND hWnd" a global parameter.
And replace:
Code:
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
With:
Code:
// Main message loop:
int i = 0;
do
{
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
i++;
char title[32];
wsprintfA(title, "%d", i );
SetWindowTextA(hWnd, title);
} while(true);
Then run the program, and in the Task Bar (Windows XP) right click window item and you'll see the Window Caption does not get updated with the new number (meaning message infinite). Also on all Window version, while moving the window (leftmouseclick on Caption bar of Window) the message loop also gets infinitely spammed with message until you let mouse go.
Proven, known issue with Windows I figured on GameDev.net already, there are only some work arounds using WM_TIMER. Most commercial games don't even bother it though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|