[RESOLVED] why Mouse Enter\Leave\Hover don't work normaly?
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)
1 Attachment(s)
Re: why Mouse Enter\Leave\Hover don't work normaly?
Quote:
Originally Posted by
Cambalinho
i see some problems:
- the mouse leave and mouse hover works in same time... why?
I just made a sample and never saw the effect.
Quote:
- the mouse messages work with client size and not window size, why?(i'm confused here)
It's just because you specify tracking flags for client area only.
See the sample: Attachment 32071
Re: why Mouse Enter\Leave\Hover don't work normaly?
Quote:
Originally Posted by
Igor Vartanov
I just made a sample and never saw the effect.
It's just because you specify tracking flags for client area only.
See the sample:
Attachment 32071
i found my error with mouse hover: tme.dwHoverTime = 1;
i changed the timer and works ;)
how i can calculate the mouse wheel position?(for see if goes down\up or left\right)
how can i test if the ctrl\alt\shift keys was pressed?
Re: why Mouse Enter\Leave\Hover don't work normaly?
Quote:
how i can calculate the mouse wheel position?(for see if goes down\up or left\right)
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
Quote:
how can i test if the ctrl\alt\shift keys was pressed?
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
Also
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
You should take some time to look at msdn.microsoft.com. This site has a lot of veryuseful information regarding development.
Re: why Mouse Enter\Leave\Hover don't work normaly?
Quote:
Originally Posted by
2kaud
and read more.. thanks for all
Re: [RESOLVED] why Mouse Enter\Leave\Hover don't work normaly?
Note for consoles, use
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
which has a mouse event record
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
which contains info abot button presses, wheel movement, button states etc
Re: [RESOLVED] why Mouse Enter\Leave\Hover don't work normaly?
Quote:
Originally Posted by
2kaud
speaking on console: the mouse move event have a bug?
why the question? because when i move the mouse and then stop, after some milliseconds(on loop time) the mouse move is activated