Shoutbox

[Help] Detecting control mouse-over - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [Help] Detecting control mouse-over (/showthread.php?tid=84743)

[Help] Detecting control mouse-over by SmokingCookie on 07-09-2008 at 05:19 PM

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.


RE: [Help] Detecting control mouse-over by matty on 07-09-2008 at 05:32 PM

You will need to monitor the window messages other then that there isn't a way.


RE: [Help] Detecting control mouse-over by SmokingCookie on 07-09-2008 at 05:33 PM

Okay, that'll do it. Thanks :D

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 :D
RE: [Help] Detecting control mouse-over by matty on 07-10-2008 at 01:24 PM

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;
    }
}


RE: [Help] Detecting control mouse-over by SmokingCookie on 07-10-2008 at 02:48 PM

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 ( " ).
RE: [Help] Detecting control mouse-over by matty on 07-10-2008 at 05:15 PM

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.
RE: [Help] Detecting control mouse-over by SmokingCookie on 07-10-2008 at 05:20 PM

It's early over there in Canada, isn't it? :P


RE: [Help] Detecting control mouse-over by Jana. on 07-21-2008 at 09:10 AM

How can I get the xy Positions out of the lParam i get back from the Message?


RE: [Help] Detecting control mouse-over by CookieRevised on 07-21-2008 at 12:20 PM

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.