 |
|
 |
Where is the source code, all i see is MouseEnterLeave.exe file
|
|
|
|
 |
|
 |
bool hoverbutton_Over = false; BOOL CMouseHoverDlg::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_MOUSEMOVE) { if (pMsg->hwnd == m_hoverbutton.GetSafeHwnd()) { if (hoverbutton_Over == false) { m_hoverbutton.SetWindowText("Click me!"); hoverbutton_Over = true; } } else { if (hoverbutton_Over == true) { m_hoverbutton.SetWindowText("Move to me!"); hoverbutton_Over = false; } } } return CDialog::PreTranslateMessage(pMsg); }
|
|
|
|
 |
|
 |
But unfortunately only works in the dialog client area...
Use _TrackMouseEvent
|
|
|
|
 |
|
 |
I have tried TrackMouseEvent on the CDialog window, everything is fine. But I have some control INSIDE the dialog, and is derived from CStatic. I have tried to work against the WM_MOUSEMOVE for that CStatic class too. But it doesn't capture any mouse event, only the CDialog does.
How can I solve this problem, or check mouse events on the elements inside CDialog?
Thankyou!
|
|
|
|
 |
|
 |
Create the CStatic using SS_NOTIFY style, or in the Dialog Editor, set the static control's Notify property to true. Hopefully, that was the problem.
|
|
|
|
 |
|
 |
This approach is incorrect. It works only if the window is the foremost window.
Too proof that it doesn't work open any window (i.e.: an explorer window) and place it in front of your dialog. Make sure that the explorer window covers only half of a button. Nove move your mouse across the border of the window. This will fire the mouse-move event on your window and the button will go to the ON state. Now try to move the mouse from the button to the explorer window across the border. Your button will remain in the ON state even tough it was supposed to be off because the mouse is now totally outside your window.
The problem is that the mouse event is fired only if your window is the foremost window.
|
|
|
|
 |
|
 |
i have a project to build a simple text editor in c++.can u people suggest some site from where i can get help???
|
|
|
|
 |
|
|
 |
|
 |
What happens if another application calls SetCapture?
An alternate method is to start a Timer (with an interval of, say, 50 ms) and keep checking to see if the mouse is within the bounds of the control. Once it's outside you call your OnMouseLeave function. Alternatively use the _TrackMouse... API as others have suggested.
cheers,
Chris Maunder
|
|
|
|
 |
|
 |
Exactly where in the code sample above do you call this function? This requires retaining state--the leave function is only called if the mouse was previously IN the window.
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka
|
|
|
|
 |
|
 |
I believe this issue is more complicated. For example, when the use Alt-Tabs to another application, the current app will continue to capture mouse input. Is this not true?
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka
|
|
|
|
 |
|
 |
??? It's the correct way to handle this.
I don't think this is a serious possesion, and the evil most likely comes from your hand. Colin J Davies, The Lounge
|
|
|
|
 |
|
 |
Unless your still using Windows 95
Paul Lyons, CCPL Certified Code Project Lurker What a lonng, strange trip its been
|
|
|
|
 |
|
 |
Are there still people using W95?
Anyway, quote from the MSDN:
_TrackMouseEvent
The _TrackMouseEvent function posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time. This function calls TrackMouseEvent if it exists, otherwise it emulates it.
Requirements
Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows 98 and later.
Redistributable: Requires Internet Explorer 3.02 or later on Windows NT 4.0 and Windows 95.
Header: Declared in Commctrl.h.
Library: Use Comctl32.lib.
I don't think this is a serious possesion, and the evil most likely comes from your hand. Colin J Davies, The Lounge
|
|
|
|
 |
|
 |
I havent looked at the function for a while, but if I remember correctly, TrackMouseEvent() is ***** useless. As it only works ONCE
"Life begins at 140"
|
|
|
|
 |
|
 |
Yep, this is exactly as it should behave. RTFM. So? After a notification you call it again with the same parameters to handle the next event.
Similar to any hook, where you must call CallNextWhateverHook() to continue handling.
I don't think this is a serious possesion, and the evil most likely comes from your hand. Colin J Davies, The Lounge
|
|
|
|
 |
|
 |
Whether or not it *should* behave that way is debatable, that's just how it's documented to behave. In what way is this like a hook anyway? It would have been better implemented similar to CS_DBLCLKS. (or should it be the other way around? Should you have to tell the OS, "Oh, by the way, I want to know next time the user double clicks here" every time you get the event?)
|
|
|
|
 |
|
 |
RabidCow wrote:
Should you have to tell the OS, "Oh, by the way, I want to know next time the user double clicks here" every time you get the event?
Most API's developed just before W95 appeared behave a bit strange. Seems that they got a whole bunch of developers with few experience to implement as much as possible in as few time as possible to complete W95.
I don't think this is a serious possesion, and the evil most likely comes from your hand. Colin J Davies, The Lounge
|
|
|
|
 |
|
 |
Andreas Saurwein wrote:
Most API's developed just before W95 appeared behave a bit strange. Seems that they got a whole bunch of developers with few experience to implement as much as possible in as few time as possible to complete W95.
Now that's the brightest thing I've heard all day! Makes a lot of sense considering the awkward mouse events implemented (awkward from a modern perspective that is).
I've been thinking about this issue too, and if TrackMouseEvent doesn't work for you, I think using a WM_TIMER of 50 or so ms is the next best effort.
extollIT Solutions
http://www.extollit.com
|
|
|
|
 |
|
 |
We still use MS-DOS and compiled MS-BASIC here at work.
Win95 is just a bit too advanced for our liking.
Neil
|
|
|
|
 |
|
 |
I suppose you make heavy use of the components found on CP too.
I don't think this is a serious possesion, and the evil most likely comes from your hand. Colin J Davies, The Lounge
|
|
|
|
 |
|
 |
Yep, that's the way I do it, and it works like a charm
But, to be honest, I don't care much about Win95 users
regards
|
|
|
|
 |
|
 |
I always use TrackMouseEvent(), it's usefull, but sometimes it can't work properly, I SWEAR.
"Hi" - greeting from a Chinese
|
|
|
|
 |