Sign in to follow this  
Followers 0
VixinG

Mouseover functions stop working after lost focus

4 posts in this topic

#1 ·  Posted (edited)

I couldn't find solution anywhere. This looks like a simple problem...

I have created a Gui with images and invisible labels over them (this is the entire gui):

Posted Image

simplified code:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include "Icons.au3"
#include "WinSnap.au3"
$GUI = GUICreate("Station Changer",480,25,0,0,$WS_POPUP+$WS_VISIBLE,$WS_EX_TOPMOST)
$all = GUICtrlCreatePic('',110,1,0,0)
GuiCtrlSetState(-1, $GUI_DISABLE)
$all_png = "all.png"
$all_png2 = "all2.png"
_SetImage($all, $all_png)
$all_label = GUICtrlCreateLabel('',110,1,44,23)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$all_UnderCursor = False
_WinSnap_Set($GUI)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    $cursor = GUIGetCursorInfo()
    If Not @error Then
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $cursor[4] = $all_label And $all_UnderCursor = False
                _SetImage($all,$all_png2)
                $all_UnderCursor = True
           Case $cursor[4] = $all_label And $all_UnderCursor
                _SetImage($all,$all_png)
                $all_UnderCursor = False
EndSelect
    EndIf
WEnd

In that case, whenever a mouse cursor is moved over the label "$all_label", the pictures are changing (from dark to highlighted). But still, if the gui is topmost and I have focus on another window, the 'mouseover' functions are no longer working. Why ?

Edited by VixinG

[indent=3][/indent]

Share this post


Link to post
Share on other sites



VixinG,

When your GUI is not active, you get an error return from GUIGetCursorInfo - so your script never looks at the mouseover section of the script. ;)

The solution is to use the winhandle parameter with GUIGetCursorInfo - then the array is returned even when your GUI is not active (as the Help file explains). :)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

God I'm so dumb ;) I need to read every word in help file of every single function in my script.

Thanks again Melba23, you are great.


[indent=3][/indent]

Share this post


Link to post
Share on other sites

VixinG,

I need to read every word in help file of every single function in my script

Very sound advice which I wish more people would take. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  
Followers 0