[Help] Detecting control mouse-over |
Author: |
Message: |
SmokingCookie
Senior Member
Posts: 815 Reputation: 15
30 / /
Joined: Jul 2007
|
O.P. [Help] Detecting control mouse-over
Hi,
I would like to detect if the mouse pointer is over a specified control.
Is this possible, and if so, which functions should I use (I guess it has to do with the Windows API?)?
Thanks in advance.
|
|
07-09-2008 05:19 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: [Help] Detecting control mouse-over
You will need to monitor the window messages other then that there isn't a way.
|
|
07-09-2008 05:32 PM |
|
|
SmokingCookie
Senior Member
Posts: 815 Reputation: 15
30 / /
Joined: Jul 2007
|
O.P. RE: [Help] Detecting control mouse-over
Okay, that'll do it. Thanks
Well, I guess I was wrong about the 1st sentence of this post..
I've inserted a "OnWindowidEvent_MessageNotification", yet nothing shows up in the debugger..
My code:
code: function OnEvent_Initialize(MessengerStart) {
WndMain = MsgPlus.CreateWnd("Windows.xml","WndMain",1);
}
function OnWndMainEvent_MessageNotification(PlusWnd,wMessage,wParam,lParam) {
Debug.Trace("> Got message \"" + wMessage + "\" with wParam \"" + wParam + "\" and lParam \"" + lParam + "\"");
}
No, I was right
This post was edited on 07-09-2008 at 06:03 PM by SmokingCookie.
|
|
07-09-2008 05:33 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: [Help] Detecting control mouse-over
The problem with this:
quote: Originally posted by SmokingCookie
code: Debug.Trace("> Got message \"" + wMessage + "\" with wParam \"" + wParam + "\" and lParam \"" + lParam + "\"");
Is that you aren't defining any messages to watch. And your \ should be \\. Check the code below to get an idea:
code: function OnEvent_Initialize(MessengerStart) {
WndMain = MsgPlus.CreateWnd("Windows.xml","WndMain",1);
WndMain.RegisterMessageNotification(0x200 /* WM_MOUSEMOVE */)
}
function OnWndMainEvent_MessageNotification(PlusWnd,wMessage,wParam,lParam) {
switch(nMessage){
case 0x200 /* WM_MOUSEMOVE */:
// do stuff here
break;
}
}
This post was edited on 07-17-2008 at 02:06 PM by matty.
|
|
07-10-2008 01:24 PM |
|
|
SmokingCookie
Senior Member
Posts: 815 Reputation: 15
30 / /
Joined: Jul 2007
|
O.P. RE: [Help] Detecting control mouse-over
Hi,
Thanks for the advice
Actually my piece of code was more to see if my window would receive any messages at all (it appeared not to receive them, because I did not register them..).
And about the \:
The debugger would say something like this:
code: > Function called: OnWndMainEvent_MessageNotification
> Got message "78" with wParam "10119" and lParam "456204"
The \" means that the text to show in the debugger hasn't ended yet, but does contain a quotation mark ( " ).
This post was edited on 07-10-2008 at 02:53 PM by SmokingCookie.
|
|
07-10-2008 02:48 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: [Help] Detecting control mouse-over
quote: Originally posted by SmokingCookie
The \" means that the text to show in the debugger hasn't ended yet, but does contain a quotation mark ( " ).
Haha!
I wasn't paying attention! By default Plus! wont make your script aware of any events unless you specifically tell it you want to know about them.
|
|
07-10-2008 05:15 PM |
|
|
SmokingCookie
Senior Member
Posts: 815 Reputation: 15
30 / /
Joined: Jul 2007
|
O.P. RE: [Help] Detecting control mouse-over
It's early over there in Canada, isn't it?
|
|
07-10-2008 05:20 PM |
|
|
Jana.
New Member
Posts: 9
Joined: Jul 2008
|
RE: [Help] Detecting control mouse-over
How can I get the xy Positions out of the lParam i get back from the Message?
|
|
07-21-2008 09:10 AM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: [Help] Detecting control mouse-over
quote: Originally posted by Jana.
How can I get the xy Positions out of the lParam i get back from the Message?
For stuff like that it is always a good idea to look things up in the MSDN Library:
=> WM_MOUSEMOVE
quote: x is the low word of the double word lParam variable
y is the high word of the double word lParam variable
thus:
var x = lParam & 0xFFFF
var y = lParam >>> 16
don't confuse >>> (unsigned right shift operator) with >> (signed right shift operator). See Windows scripting docs for detailed info.
PS: also read " The Old New Thing: Why do I get spurious WM_MOUSEMOVE messages?" if you want to use WM_MOUSEMOVE.
PS: Checking mouse movement over a control with the WM_MOUSEMOVE Windows Message is possible, but does not provide ways to detect if the mouse moved out of the control. For that you need to setup a mouse tracking/capturing message with the Windows API SetCapture.
This post was edited on 07-21-2008 at 12:52 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
07-21-2008 12:20 PM |
|
|
|