Windows Message Cracking
Message cracking is a natural by-product of encapsulating the WPARAM and LPARAM of a Windows event in an object. Calling member functions to crack a Windows message is more convenient and type-safe than using macros. Windows procedure that cracks mouse events and saves the event point illustrates a window procedure that cracks mouse events and saves the point at which the mouse event occurred.
Windows procedure that cracks mouse events and saves the event point
static POINT g_ptLast;
LRESULT WndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
static CEventFactory factory;
IEvent* pEvent = factory.CreateWindowsEvent(nMsg, wParam, lParam);
IMouseEvent* pMouseEvent = guid_cast<IMouseEvent*>(pEvent);
if (pMouseEvent != NULL)
{
pMouseEvent->GetPoint(g_ptLast);
}
. . .
}






