Loc Posted July 2, 2021 Share Posted July 2, 2021 How to Hover over 2 labels without blinking when changing color of label setbkcolor with disabled state. I tried 1 label not blinking, but when trying 2 labels it blinks. I am creating 1 button with 2 labels. 1 is the name 2 is the comment expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> Global $hGUI, $fOver = False, $LbsetOver $hGUI = GUICreate("Test Hover", 500, 500) $LbsetOver = GUICtrlCreateLabel("", 8, 8, 84, 59) GUICtrlSetBkColor($LbsetOver, 0x000000) GUICtrlSetState($LbsetOver, $GUI_DISABLE) $LbOver = GUICtrlCreateLabel("Press Me!", 10, 10, 80, 30, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xFFF805) $LbOverPlus = GUICtrlCreateLabel("Plus", 10, 40, 80, 25, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xFFF805) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch _GUICtrlHover($hGUI, $LbOver) _GUICtrlHover($hGUI, $LbOverPlus) WEnd Func _GUICtrlHover($hwmdover, $ctrlover) $aCInfo = GUIGetCursorInfo($hwmdover) If $aCInfo[4] = $ctrlover Then If $fOver = False Then GUICtrlSetBkColor($LbsetOver, 0xFFFFFF) $fOver = True EndIf Else If $fOver = True Then GUICtrlSetBkColor($LbsetOver, 0x000000) $fOver = False EndIf EndIf EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 2, 2021 Moderators Share Posted July 2, 2021 Loc, Try this: expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> Global $hGUI, $fOver = False, $LbsetOver $hGUI = GUICreate("Test Hover", 500, 500) $LbsetOver = GUICtrlCreateLabel("", 8, 8, 84, 59) GUICtrlSetBkColor($LbsetOver, 0x000000) GUICtrlSetState($LbsetOver, $GUI_DISABLE) $LbOver = GUICtrlCreateLabel("Press Me!", 10, 10, 80, 30, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xFFF805) $LbOverPlus = GUICtrlCreateLabel("Plus", 10, 40, 80, 25, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xFFF805) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch _GUICtrlHover($hGUI, $LbOver, $LbOverPlus) WEnd Func _GUICtrlHover($hwmdover, $ctrl1, $ctrl2) $aCInfo = GUIGetCursorInfo($hwmdover) If $aCInfo[4] = $ctrl1 Or $aCInfo[4] = $ctrl2 Then ; Over labels If $fOver = False Then GUICtrlSetBkColor($LbsetOver, 0xFFFFFF) $fOver = True EndIf Else ; Not over labels If $fOver = True Then GUICtrlSetBkColor($LbsetOver, 0x000000) $fOver = False EndIf EndIf EndFunc M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Nine Posted July 2, 2021 Share Posted July 2, 2021 A little different : #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Local $hGUI = GUICreate("Test Hover", 500, 500) Local $LbsetOver = GUICtrlCreateLabel("", 8, 8, 84, 59) GUICtrlSetBkColor($LbsetOver, 0x000000) GUICtrlSetState($LbsetOver, $GUI_DISABLE) Local $LbOver = GUICtrlCreateLabel("Press Me!", 10, 10, 80, 30, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xFFF805) Local $LbOverPlus = GUICtrlCreateLabel("Plus", 10, 40, 80, 25, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xFFF805) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch _GUICtrlHover($hGUI, $LbOver, $LbOverPlus) WEnd Func _GUICtrlHover($hwmdover, $ctrlover, $ctrloverPlus) Local Static $sOver Local $aCInfo = GUIGetCursorInfo($hwmdover) If $aCInfo[4] = $sOver Then Return $sOver = $aCInfo[4] If $aCInfo[4] = $ctrlover Then GUICtrlSetBkColor($LbsetOver, 0xFFFFFF) ElseIf $aCInfo[4] = $ctrloverPlus Then GUICtrlSetBkColor($LbsetOver, 0x000000) EndIf EndFunc ;==>_GUICtrlHover “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Loc Posted July 2, 2021 Author Share Posted July 2, 2021 Thanks for the help. I'm not at the computer right now. $LbOver and $LbOverPlus it can contain [100] and $Lbsetover[100] So you can use For $i = 1 to 99 $ainfo = GUIGetCursorInfo() If $ainfo[4] = $LbOver[$i] Then Guictrlsetbkcolor($Lbsetover[$i]) ElseIf $ainfo[4] = $LbOverPlus[$i] Then Guictrlsetbkcolor($Lbsetover[$i]) Endif next My loop has many functions running and in all functions there is no sleep. When adding _GUICtrlHover() function into the loop, its get the hover function slower than guictrlcreatebutton on hover. Is there any way to improve the speed? I wrote the code according to the incomplete illustration, please forgive me Link to comment Share on other sites More sharing options...
Nine Posted July 2, 2021 Share Posted July 2, 2021 I do not think my approach should slow your script down whatever the number of labels you have. If it does, then make a replicate so we can take a look at it... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Loc Posted July 3, 2021 Author Share Posted July 3, 2021 I mean create multiple buttons with 2 labels like this. Button generated can be up to 200. Is there a way to fix flickering with multiple generated buttons? expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> Global $hGUI, $fOver = False, $LbsetOver[2], $LbOver[2], $LbOverPlus[2] $hGUI = GUICreate("Test Hover", 500, 500) $LbsetOver[0] = GUICtrlCreateLabel("", 8, 8, 84, 59) GUICtrlSetBkColor($LbsetOver, 0x000000) GUICtrlSetState($LbsetOver, $GUI_DISABLE) $LbOver[0] = GUICtrlCreateLabel("Press Me!", 10, 10, 80, 30, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xFFF805) $LbOverPlus[0] = GUICtrlCreateLabel("Plus", 10, 40, 80, 25, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xFFF805) $LbsetOver[1] = GUICtrlCreateLabel("", 98, 8, 84, 59) GUICtrlSetBkColor($LbsetOver, 0x000000) GUICtrlSetState($LbsetOver, $GUI_DISABLE) $LbOver[1] = GUICtrlCreateLabel("Press Me!", 100, 10, 80, 30, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xFFF805) $LbOverPlus[1] = GUICtrlCreateLabel("Plus", 100, 40, 80, 25, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xFFF805) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch For $i = 0 To 1 _GUICtrlHover($hGUI, $LbOver[$i], $LbOverPlus[$i], $LbsetOver[$i]) Next WEnd Func _GUICtrlHover($hwmdover, $ctrl1, $ctrl2, $ctrlsetbkcolor) $aCInfo = GUIGetCursorInfo($hwmdover) If $aCInfo[4] = $ctrl1 Or $aCInfo[4] = $ctrl2 Then ; Over labels If $fOver = False Then GUICtrlSetBkColor($ctrlsetbkcolor, 0xFFFFFF) $fOver = True EndIf Else ; Not over labels If $fOver = True Then GUICtrlSetBkColor($ctrlsetbkcolor, 0x000000) $fOver = False EndIf EndIf EndFunc Link to comment Share on other sites More sharing options...
Nine Posted July 3, 2021 Share Posted July 3, 2021 (edited) Here how I would do it : expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> Global $hGUI, $LbsetOver[2], $LbOver[2], $LbOverPlus[2] $hGUI = GUICreate("Test Hover", 500, 500) $LbsetOver[0] = GUICtrlCreateLabel("", 8, 8, 84, 59) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetState(-1, $GUI_DISABLE) $LbOver[0] = GUICtrlCreateLabel("Press Me!", 10, 10, 80, 30, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xFFF805) $LbOverPlus[0] = GUICtrlCreateLabel("Plus", 10, 40, 80, 25, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xFFF805) $LbsetOver[1] = GUICtrlCreateLabel("", 98, 8, 84, 59) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetState(-1, $GUI_DISABLE) $LbOver[1] = GUICtrlCreateLabel("Press Me!", 100, 10, 80, 30, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xFFF805) $LbOverPlus[1] = GUICtrlCreateLabel("Plus", 100, 40, 80, 25, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xFFF805) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch _GUICtrlHover($hGUI, $LbOver, $LbOverPlus, $LbsetOver) WEnd Func _GUICtrlHover($hwmdover, ByRef $LbOver, ByRef $LbOverPlus, ByRef $LbsetOver) Local Static $sOver Local $aCInfo = GUIGetCursorInfo($hwmdover) If $aCInfo[4] = $sOver Then Return $sOver = $aCInfo[4] For $i = 0 To UBound($LbsetOver) - 1 If $sOver = $LbOver[$i] Then Return GUICtrlSetBkColor($LbsetOver[$i], 0xFFFFFF) Next For $i = 0 To UBound($LbsetOver) - 1 If $sOver = $LbOverPlus[$i] Then Return GUICtrlSetBkColor($LbsetOver[$i], 0x000000) Next EndFunc ;==>_GUICtrlHover Edited July 3, 2021 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Loc Posted July 3, 2021 Author Share Posted July 3, 2021 @Nine Looks like it only jumps in the $LbOver and $LbOverPlus variables, but when it goes out, it doesn't change. I mean when hovering on one of the 2 controls, it will change the color of the border, don't move the mouse on the first ctrl, then ctrl 2 will change the color and vice versa @@ Link to comment Share on other sites More sharing options...
Nine Posted July 3, 2021 Share Posted July 3, 2021 I dont understand what you mean. If the behavior is not what you are expecting, just adapt the code. From my side there is no flickering at all, and this is what you were asking in the first place. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Loc Posted July 3, 2021 Author Share Posted July 3, 2021 bandicam 2021-07-03 19-26-19-411.mp4 Link to comment Share on other sites More sharing options...
Loc Posted July 3, 2021 Author Share Posted July 3, 2021 2 Labels = 1 button. When jumping over another button, the old button color returns to the original state. Link to comment Share on other sites More sharing options...
Nine Posted July 3, 2021 Share Posted July 3, 2021 The video is blank. Do you mean that when you leave a button, it SHOULD return to the original state (ie. black) ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Loc Posted July 3, 2021 Author Share Posted July 3, 2021 Right. I made it like 1 button so it's just 2 labels so I can write 2 lines like that Link to comment Share on other sites More sharing options...
Nine Posted July 4, 2021 Share Posted July 4, 2021 DO NOT PM me asking for help. I have other activities beside answering to your issues. Anyway, my last attempt here : Func _GUICtrlHover($hwmdover, ByRef $LbOver, ByRef $LbOverPlus, ByRef $LbsetOver) Local Static $sOver, $iPrev = -1 Local $aCInfo = GUIGetCursorInfo($hwmdover) If $aCInfo[4] = $sOver Then Return $sOver = $aCInfo[4] If $iPrev >= 0 Then GUICtrlSetBkColor($LbsetOver[$iPrev], 0x000000) For $i = 0 To UBound($LbsetOver) - 1 If $sOver = $LbOver[$i] Then $iPrev = $i Return GUICtrlSetBkColor($LbsetOver[$i], 0xFFFFFF) EndIf Next For $i = 0 To UBound($LbsetOver) - 1 If $sOver = $LbOverPlus[$i] Then If $iPrev >= 0 Then GUICtrlSetBkColor($LbsetOver[$i], 0x000000) ExitLoop EndIf Next $iPrev = -1 EndFunc ;==>_GUICtrlHover FYI, it is against forum rules to PM for help. I suggest you read those to refresh your memory... Loc 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Loc Posted July 4, 2021 Author Share Posted July 4, 2021 Yes. I do not know that. I have PM for 2 people today. Dan and Nine, I will learn from experience Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now