-
November 12th, 2013, 03:00 PM
#1
[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)
-
November 13th, 2013, 04:39 AM
#2
Re: why Mouse Enter\Leave\Hover don't work normaly?
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.
- 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: HOWTO-hover-leave-client-nonclient.zip
Best regards,
Igor
-
November 13th, 2013, 08:28 AM
#3
Re: why Mouse Enter\Leave\Hover don't work normaly?
Originally Posted by Igor Vartanov
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?
-
November 13th, 2013, 08:39 AM
#4
Re: why Mouse Enter\Leave\Hover don't work normaly?
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
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.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
November 13th, 2013, 08:43 AM
#5
Re: why Mouse Enter\Leave\Hover don't work normaly?
Originally Posted by 2kaud
and read more.. thanks for all
-
November 13th, 2013, 08:57 AM
#6
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
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
November 13th, 2013, 01:59 PM
#7
Re: [RESOLVED] why Mouse Enter\Leave\Hover don't work normaly?
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
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
|