I call it WM_HOVERTITLEBAR but that may be wordy for some. Call it what you like
Ken: could you cout << me one? Pleeeeze?
[/code]
is that really speeding you up that much not to call TranslateMessage and DispatchMessage?
certainly.
The increased speed can be substantial, dependent on such factors as relative volume in the system, the types of messages , and the processor speed.
Below is an example message pump.
I implement it as a list that serves as a filter. This structure is quite lean, composed of nothing more than a UINT and a forward and backward pointer. All messages are loaded into the list either by default, by semi-default, or manually, depending on the type message. For instance, you would'nt normally ignore a WM_CLOSE message would you? In my lists, all messages can be removed though. A window class inserts elements in and out of the list by request into the message stream. Custom message patterns can be created, recorded and modified too. Enjoy.
Code:
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
WPARAM RunMessageLoop()
{
int recieving;
while(recieving = GetMessage(&messages, NULL, 0, 0) != 0)
{
if(recieving == -1)
{
Alert(" Fatal Windows Error ");
return recieving;
}
if( messageTracker.Has(messages.message) ) //...the rest won't even make it to the window procedure!!
{
DispatchMessage(&messages);
TranslateMessage(&messages);
SendMessage(hwnd, messages.message, messages.wParam, messages.lParam);
}
// /else Alert("New Message: %d", messages.message); / //
}
return messages.wParam;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
void AddDefaultMessages()
{
AddMessage(WM_NCCREATE);
AddMessage(WM_CREATE);
AddMessage(WM_PAINT);
AddMessage(WM_SIZE);
AddMessage(WM_NCLBUTTONDOWN);
AddMessage(WM_NCLBUTTONUP);
AddMessage(WM_NCLBUTTONDBLCLK);
AddMessage(WM_KEYUP);
AddMessage(WM_KEYDOWN);
AddMessage(WM_LBUTTONDOWN);
AddMessage(WM_RBUTTONDOWN);
AddMessage(WM_LBUTTONUP);
AddMessage(WM_RBUTTONUP);
AddMessage(WM_DESTROY);
AddMessage(WM_CLOSE);
AddMessage(WM_QUIT);
// / etc
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
bool AddMessage(UINT message)
{
if( messageTracker.Has(message) ) //...already has message...
return false;
messageTracker.Push(message);
return true;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
bool RemoveMessage(UINT message)
{
List <UINT> *messageFound = messageTracker.Has(message);
if(messageFound == NULL) //...didn't find message...
return false;
messageTracker.Remove(messageFound);
return true;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//