Jump to content
Sign in to follow this  
4Eyes

How to get msg's from controls while moving mouse with left button down

Recommended Posts

4Eyes

Folks,

I have a bunch of controls (labels actually) that I'd like to get messages from while moving the mouse over them with left button depressed. That is, select one control then get a message from any other as the mouse is moved over it.

I was using $GUI_EVENT_MOUSEMOVE and determining the relative position but that is unreliable due to height of menu bar and maybe other differences between XP and Windows 7.

I looked at registering a message but I'm a novice with that stuff. Doesn't appear to be a style I can use with GuiCtrlCreate... funcs either.

Can somebody please make a suggestion?

[Edit] Just found MrCreatoR's GUICtrlSetOnHover UDF which looks like the answer.

Edited by 4Eyes

Share this post


Link to post
Share on other sites
4Eyes

Is there no solution to this?

As I can't obfuscate the GUICtrlSetOnHover UDF, it has to be at least temporarily shelved.

I could change the labels to buttons but that doesn't change the undderlying issue I think. Major sigh...

Share this post


Link to post
Share on other sites
smashly

Hi,

Global $hGui, $aGCCI, $iLastID

$hGui = GUICreate("")
For $i = 0 To 4
    GUICtrlCreateLabel("Label " & $i + 1, 5, 5 + ($i * 35), 60, 20)
Next
GUISetState(@SW_SHOW, $hGui)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case Else
            $aGCCI = GUIGetCursorInfo($hGui)
            If $aGCCI[2] And $aGCCI[4] And $iLastID <> $aGCCI[4] Then
                $iLastID = $aGCCI[4]
                ConsoleWrite("LMB Down and over Control ID: " & $iLastID & " - Control Text: " & GUICtrlRead($iLastID) & @LF)
            Else
                $iLastID = $aGCCI[4]
            EndIf
    EndSwitch
WEnd

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites
4Eyes

smashly,

GuiGetCursorInfo? I've never used that before and while I did see it in the help file I glossed over it for this purpose due to the name.... "I don't need cursor info!".

That is certainly more elegent (and correct) than the solution I just finished debugging which uses relative positioning based on the position of another control. I had difficulties until I used Opt("MouseCoordMode", 2) which then removes variables like the height of the menu bar, large desktop fonts etc.

That's really helpful and I thank you, kind sir.

Edited by 4Eyes

Share this post


Link to post
Share on other sites
monoscout999

1 - i can ofuscate GuiCtrlSetOnHover but only Striped the functions, you should add manually the function that the ofuscator cant ofuscate

2 - GuiGetCurorInfo is what you need :mellow:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×