i'm learning more about windows messages:
Code:
void TrackMouse(HWND hwnd)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_HOVER | TME_LEAVE; //Type of events to track & trigger.
tme.dwHoverTime = 1; //How long the mouse has to be in the window to trigger a hover event.
tme.hwndTrack = hwnd;
TrackMouseEvent(&tme);
}
// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static bool Tracking = false;
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_KEYUP:
if (wParam ==VK_ESCAPE)
DestroyWindow(hwnd);
else
{
char strDataToSend[32];
sprintf(strDataToSend, "%c", wParam);
MessageBox(NULL,strDataToSend, "keyselected",MB_OK);
}
break;
case WM_MOUSEMOVE:
if (!Tracking)
{
TrackMouse(hwnd);
Tracking = true;
SetWindowText(hwnd,"MOUSE Entered");
}
break;
case WM_MOUSEHOVER:
SetWindowText(hwnd,"MOUSE hover");
break;
case WM_MOUSELEAVE:
SetWindowText(hwnd,"MOUSE LEFT");
Tracking = false;
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
i see some problems:
- the mouse leave and mouse hover works in same time... why?
- the mouse messages work with client size and not window size, why?(i'm confused here)