jmon Posted November 28, 2012 Posted November 28, 2012 (edited) Hello,I am trying to change the z-ordering of controls in my GUI using GUICtrlSetState. How come this example don't work? (I want $LABEL1 to be above $LABEL2)#include <GUIConstantsEx.au3> $GUI = GUICreate("Test", 800, 600) GUISetState() $LABEL1 = GUICtrlCreateLabel("under", 20, 20, 500, 300) GUICtrlSetBkColor(-1, 0xFF0000) $LABEL2 = GUICtrlCreateLabel("above", 40, 60, 500, 300) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlSetState($LABEL1, $GUI_ONTOP) Do Sleep(50) Until GUIGetMsg() = -3 ExitIs there another method to change the z ordering and the order controls receive clicks? I know that the controls should be created in the correct order, but I can't in the script I am doing now.Thanks[EDIT] Solution is in post #5 Edited November 29, 2012 by jmon [center]www.jmontserrat.comFile Sequence UDF - _StringExtractPaths - _StringTrimPattern - GuiCtrlSetOnTop - CalendarUDF[/center]
jmon Posted November 29, 2012 Author Posted November 29, 2012 (edited) So I tested other options, and this one doesn't work either:#include <GUIConstantsEx.au3> #include <WinAPIEx.au3> $GUI = GUICreate("Test", 800, 600) GUISetState() $LABEL1 = GUICtrlCreateLabel("under", 20, 20, 500, 300) GUICtrlSetBkColor(-1, 0xFF0000) $LABEL2 = GUICtrlCreateLabel("above", 40, 60, 500, 300) GUICtrlSetBkColor(-1, 0x00FF00) _WinAPI_BringWindowToTop(GUICtrlGetHandle($LABEL1)) Do Sleep(50) Until GUIGetMsg() = -3 Exit[EDIT]This one doesn't seems to work either#include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <APIConstants.au3> $GUI = GUICreate("Test", 800, 600) GUISetState() $LABEL1 = GUICtrlCreateLabel("under", 20, 20, 500, 300) GUICtrlSetBkColor(-1, 0xFF0000) $LABEL2 = GUICtrlCreateLabel("above", 40, 60, 500, 300) GUICtrlSetBkColor(-1, 0x00FF00) $aPos = ControlGetPos(GUICtrlGetHandle($LABEL1), "", 0) _WinAPI_SetWindowPos(GUICtrlGetHandle($LABEL1), $HWND_TOP, $aPos[0], $aPos[1], $aPos[2], $aPos[3], $SWP_NOMOVE) Do Sleep(50) Until GUIGetMsg() = -3 Exit[EDIT] Actually it works but with these parameters:#include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <APIConstants.au3> $GUI = GUICreate("Test", 800, 600) GUISetState() $LABEL1 = GUICtrlCreateLabel("under", 20, 20, 500, 300) GUICtrlSetBkColor(-1, 0xFF0000) $LABEL2 = GUICtrlCreateLabel("above", 40, 60, 500, 300) GUICtrlSetBkColor(-1, 0x00FF00) $aPos = ControlGetPos(GUICtrlGetHandle($LABEL1), "", 0) _WinAPI_SetWindowPos(GUICtrlGetHandle($LABEL1), GUICtrlGetHandle($LABEL2), $aPos[0, $aPos[1], $aPos[2], $aPos[3], $SWP_NOCOPYBITS) Do Sleep(50) Until GUIGetMsg() = -3 ExitNow, even if this works, I'm still looking for a method that wouldn't move the control and that wouldn't need to tell which control to draw over. Edited November 29, 2012 by jmon [center]www.jmontserrat.comFile Sequence UDF - _StringExtractPaths - _StringTrimPattern - GuiCtrlSetOnTop - CalendarUDF[/center]
czardas Posted November 29, 2012 Posted November 29, 2012 (edited) It's possible Microsoft changed how the z-Index can be alterred (I may have read something like that - though I'm not entirely sure). Even if this is not the case, it does not automatically follow that the GUI controls will be automatically repainted (once again - I don't know). I do think that overlapping controls is generally best avoided. Depending on what you want to achieve, there may be a work around or an alternative method. You can always destroy your controls and create them again in reverse order. Edited November 29, 2012 by czardas operator64 ArrayWorkshop
jmon Posted November 29, 2012 Author Posted November 29, 2012 (edited) @czardas : thank you for the information I actually found the solution: #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <APIConstants.au3> $GUI = GUICreate("Test", 800, 600) GUISetState() $LABEL1 = GUICtrlCreateLabel("under", 20, 20, 500, 300) GUICtrlSetBkColor(-1, 0xFF0000) $LABEL2 = GUICtrlCreateLabel("above", 40, 60, 500, 300) GUICtrlSetBkColor(-1, 0x00FF00) GuiCtrlSetOnTop($LABEL1) Do Sleep(50) Until GUIGetMsg() = -3 Exit Func GuiCtrlSetOnTop($iCtrlID) ;Need to include <WinAPI.au3> and <APIConstants.au3> Local $hWnd = $iCtrlID If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($iCtrlID) Return _WinAPI_SetWindowPos($hWnd, $HWND_BOTTOM, 0, 0, 0, 0, $SWP_NOMOVE + $SWP_NOSIZE + $SWP_NOCOPYBITS) EndFunc This method doesn't require to tell the position or the control to be drawn ontop. I made a quick snippet that you can include in your scripts. Edited November 29, 2012 by jmon DickG and p4sCh 2 [center]www.jmontserrat.comFile Sequence UDF - _StringExtractPaths - _StringTrimPattern - GuiCtrlSetOnTop - CalendarUDF[/center]
czardas Posted November 29, 2012 Posted November 29, 2012 I actually need to check the information I posted above. I'm glad you managed to find a solution anyway. operator64 ArrayWorkshop
jmon Posted November 29, 2012 Author Posted November 29, 2012 Thanks.I posted a snippet and for more information about SetWindowPos, check out MSDN. Maybe I should add some other flags? [center]www.jmontserrat.comFile Sequence UDF - _StringExtractPaths - _StringTrimPattern - GuiCtrlSetOnTop - CalendarUDF[/center]
jmon Posted November 29, 2012 Author Posted November 29, 2012 So even though I found an answer to my question, I was wondering what was GUICtrlSetState($LABEL1, $GUI_ONTOP) supposed to do? What is this constant for is it's not to set a control on top? [center]www.jmontserrat.comFile Sequence UDF - _StringExtractPaths - _StringTrimPattern - GuiCtrlSetOnTop - CalendarUDF[/center]
guinness Posted November 29, 2012 Posted November 29, 2012 So even though I found an answer to my question, I was wondering what was GUICtrlSetState($LABEL1, $GUI_ONTOP) supposed to do? What is this constant for is it's not to set a control on top? Hmm, strange. Perhaps this is a bug? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
jmon Posted November 29, 2012 Author Posted November 29, 2012 Hmm, strange. Perhaps this is a bug?Yes it looks like it. I haven't found any use for this constant... [center]www.jmontserrat.comFile Sequence UDF - _StringExtractPaths - _StringTrimPattern - GuiCtrlSetOnTop - CalendarUDF[/center]
guinness Posted November 29, 2012 Posted November 29, 2012 If this is the case then report to Trac. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
jmon Posted November 29, 2012 Author Posted November 29, 2012 Ok, Done [center]www.jmontserrat.comFile Sequence UDF - _StringExtractPaths - _StringTrimPattern - GuiCtrlSetOnTop - CalendarUDF[/center]
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