Jump to content

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


4Eyes
 Share

Recommended Posts

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
Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...