Steve0 Posted September 1, 2010 Share Posted September 1, 2010 Hey guys,I've got a number of standard pictures on a GUI overlapping each other. Using the GUICtrlOnHover UDF I've been trying (unsuccessfully) to have the images "bring to front". Koda has this option when editing the GUI, but doing so makes no changes in the form code.Setting the Ctrl State to $GUI_FOCUS, $GUI_ENABLE, $GUI_SHOW or $GUI_ONTOP makes no difference, nor does setting the Ctrl Style to $WS_EX_TOPMOST.Any other suggestions?Many thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 1, 2010 Moderators Share Posted September 1, 2010 Steve0, This is a bit sledgehammer/nut but it does work: expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> Global $aLabels[4], $aColours[4] = [0xFF0000, 0xFFFF00, 0x00FF00, 0x0000FF] $hGUI = GUICreate("Test", 500, 500) $hStart = GUICtrlCreateDummy() $aLabels[0] = GUICtrlCreateLabel("", 10, 10, 100, 100) GUICtrlSetBkColor(-1, $aColours[0]) $aLabels[1] = GUICtrlCreateLabel("", 60, 60, 100, 100) GUICtrlSetBkColor(-1, $aColours[1]) $aLabels[2] = GUICtrlCreateLabel("", 110, 110, 100, 100) GUICtrlSetBkColor(-1, $aColours[2]) $aLabels[3] = GUICtrlCreateLabel("", 160, 160, 100, 100) GUICtrlSetBkColor(-1, $aColours[3]) GUISetState() $hLastCtrl = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $aInfo = GUIGetCursorInfo($hGUI) If $aInfo[4] <> $hLastCtrl And $aInfo[4] <> 0 Then ConsoleWrite("Current Ctrl: " & $aInfo[4] & @CRLF) $iIndex = _ArraySearch($aLabels, $aInfo[4]) ConsoleWrite("Index: " & $iIndex & @CRLF) $aPos = ControlGetPos($hGUI, "", $aInfo[4]) GUICtrlDelete($aInfo[4]) $aLabels[$iIndex] = GUICtrlCreateLabel("", $aPos[0], $aPos[1], $aPos[2], $aPos[3]) GUICtrlSetBkColor($aLabels[$iIndex], $aColours[$iIndex]) $hLastCtrl = $aLabels[$iIndex] EndIf WEnd I will try and come up with something better! 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...
picea892 Posted September 1, 2010 Share Posted September 1, 2010 Hi there. Just a tweak to Melba's Redraw the control instead of deleting and remaking. #include <GUIConstantsEx.au3> #include <Array.au3> #include <Winapi.au3> Global $aLabels[4], $aColours[4] = [0xFF0000, 0xFFFF00, 0x00FF00, 0x0000FF] $hGUI = GUICreate("Test", 500, 500) $over=10 for $i=0 to 3 $aLabels[$i] = GUICtrlCreateLabel("", $over, $over, 100, 100) GUICtrlSetBkColor(-1, $aColours[$i]) $over=$over+50 Next GUISetState() $hLastCtrl = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $aInfo = GUIGetCursorInfo($hGUI) If $aInfo[4] <> $hLastCtrl And $aInfo[4] <> 0 Then $hLastCtrl=$aInfo[4] _WinAPI_RedrawWindow(GUICtrlGetHandle($aInfo[4])) EndIf WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 1, 2010 Moderators Share Posted September 1, 2010 picea892, I knew there must be a better tool than a sledgehammer out there! Thanks for pointing it out! 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...
Steve0 Posted September 2, 2010 Author Share Posted September 2, 2010 Many thanks for the quick response guys, works well! Link to comment Share on other sites More sharing options...
Steve0 Posted September 2, 2010 Author Share Posted September 2, 2010 Sorry guys, the example worked perfectly... maybe I'm not translating it correctly here... I've tried using the picea892 method, and it looks... funny. I've made up a sample of what I'm trying to get at using some standard WinXP graphics (not sure if they're still there on other editions):#include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> $TestWindow = GUICreate("Overlay Test", 300, 300, 150, 200, 0x00000000, 0x00000000) $Background = GUICtrlCreatePic("C:\WINDOWS\Web\Wallpaper\Ascent.jpg", 0, 0, 300, 300) GUICtrlSetState($Background, $GUI_DISABLE) GUICtrlCreatePic("C:\WINDOWS\Web\Wallpaper\Autumn.jpg", 10,10,100,100) GUICtrlCreatePic("C:\WINDOWS\Web\Wallpaper\Azul.jpg", 60,60,100,100) GUICtrlCreatePic("C:\WINDOWS\Web\Wallpaper\Autumn.jpg", 110,110,100,100) GUISetState(@SW_SHOW, $TestWindow) $hLastCtrl = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $aInfo = GUIGetCursorInfo($TestWindow) If $aInfo[4] <> $hLastCtrl And $aInfo[4] <> 0 Then $hLastCtrl=$aInfo[4] _WinAPI_RedrawWindow(GUICtrlGetHandle($aInfo[4])) EndIf WEndMaking use of the WinAPI command to refresh the window but with my old code, it still doesn't "bring to front". Here's the method I was using before, utilising MrCreatoR's GUICtrlOnHover script:#include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <GUICtrlOnHover.au3> #include <WindowsConstants.au3> $TestWindow = GUICreate("Overlay Test", 300, 300, 150, 200, 0x00000000, 0x00000000) $Background = GUICtrlCreatePic("C:\WINDOWS\Web\Wallpaper\Ascent.jpg", 0, 0, 300, 300) GUICtrlSetState($Background, $GUI_DISABLE) GUICtrlCreatePic("C:\WINDOWS\Web\Wallpaper\Autumn.jpg", 10,10,100,100) _GUICtrl_OnHoverRegister(-1, "_Hover_Func", "_Leave_Hover_Func") GUICtrlCreatePic("C:\WINDOWS\Web\Wallpaper\Autumn.jpg", 60,60,100,100) _GUICtrl_OnHoverRegister(-1, "_Hover_Func", "_Leave_Hover_Func") GUICtrlCreatePic("C:\WINDOWS\Web\Wallpaper\Autumn.jpg", 110,110,100,100) _GUICtrl_OnHoverRegister(-1, "_Hover_Func", "_Leave_Hover_Func") GUISetState(@SW_SHOW, $TestWindow) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Hover_Func($iCtrlID) GUICtrlSetImage($iCtrlID, "C:\WINDOWS\Web\Wallpaper\Azul.jpg") _WinAPI_RedrawWindow($iCtrlID) EndFunc Func _Leave_Hover_Func($iCtrlID) GUICtrlSetImage($iCtrlID, "C:\WINDOWS\Web\Wallpaper\Autumn.jpg") _WinAPI_RedrawWindow($iCtrlID) EndFuncAny more assistance would be greatly appreciated! Link to comment Share on other sites More sharing options...
picea892 Posted September 2, 2010 Share Posted September 2, 2010 Hi there. First Example You'll have to exclude any controls you don't want to be affected. Your background picture becomes first and makes the "funny" effect. So you need to make this change If $aInfo[4] <> $hLastCtrl And $aInfo[4] <> 0 And $aInfo[4] <> $Background Then Second Example (Mr. Creator) You need to you use the redraw script with a handle not an ID. So your code would look like this. _WinAPI_RedrawWindow(GUICtrlGetHandle($iCtrlID)) Link to comment Share on other sites More sharing options...
Steve0 Posted September 2, 2010 Author Share Posted September 2, 2010 Superb! Both work perfectly. Many thanks for your help! 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