JohnOne Posted November 5, 2010 Posted November 5, 2010 (edited) Hi Melba. I finally got around to using this, this afternoon, but quickly ran into trouble. I wanted to use hotkeys to control the extending and retracting, so first I modified your udf for _GUIExtender_Section_Action() to return what I thought woulf be a handle to the control it made, alas it didnt work that way, so had to use the conventional way of finding the buttons ID and using that and controlclick, so that was all fine and dandy. My further problem and what I think might be a bug, occurred when I tryed to add content to the gui, the first being an IE object, and it seems to not work when its present. heres a quick repro to show. If you uncomment the line, the script fails. #include <GUIConstantsEx.au3> #include "GUIExtender.au3" HotKeySet("{HOME}","CClick") $hGUI = GUICreate("",762,710) _GUIExtender_Init($hGUI) _GUIExtender_Section_Start(0, 574) $oIE = ObjCreate("Shell.Explorer.2") ;$oWindow = GUICtrlCreateObj($oIE, 0, 0, 762, 574) _GUIExtender_Section_Action(2, "", "", 0, 580, 1, 1) _GUIExtender_Section_End() _GUIExtender_Section_Start(574, 167) _GUIExtender_Section_End() _GUIExtender_Section_Extend(2, False) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit EndSwitch _GUIExtender_Action($iMsg) WEnd Func CClick() ControlClick($hGUI,"","[CLASS:Button; INSTANCE:1]") EndFunc Edited November 5, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Moderators Melba23 Posted November 5, 2010 Author Moderators Posted November 5, 2010 JohnOne,The script fails because Objects do not return a valid array when ControlGetPos is used on them - the UDF does this to work out where they are in the section. A quick experiment shows that Objects are very special. It seems that you must use GUICtrlSetPos and not ControlMove to position them - unfortunately there is no GUICtrlGetPos to replace ControlGetPos. I will investigate further..... 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
JohnOne Posted November 5, 2010 Posted November 5, 2010 Thanks for taking the time to look M23. I dont fully understand your code, but it seems the object would not need to be moved when in a static part of the gui. I'm probably oversimplifying something which is more complicated than that though. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Moderators Melba23 Posted November 5, 2010 Author Moderators Posted November 5, 2010 JohnOne,If the Object is in the first part of the GUI which is always static then your immediate problem can be solved by simply not declaring that section: #include <GUIConstantsEx.au3> #include "GUIExtender.au3" HotKeySet("{HOME}","CClick") $hGUI = GUICreate("",762,710) _GUIExtender_Init($hGUI) $oIE = ObjCreate("Shell.Explorer.2") $oWindow = GUICtrlCreateObj($oIE, 0, 0, 762, 574) _GUIExtender_Section_Start(574, 167) _GUIExtender_Section_End() _GUIExtender_Section_Action(1, "", "", 0, 580, 1, 1) _GUIExtender_Section_Extend(1, False) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit EndSwitch _GUIExtender_Action($iMsg) WEnd Func CClick() ControlClick($hGUI,"","[CLASS:Button; INSTANCE:1]") EndFuncBut this trick only works if it is the initial section which always remains static. I will still investigate the Object location problem - it would be nice to have a more general solution. 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
JohnOne Posted November 5, 2010 Posted November 5, 2010 Ace Melba23, that solves my problem, thank you very kindly. And the last couple of hours have gotten me a little closer to following your UDF AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Moderators Melba23 Posted November 17, 2010 Author Moderators Posted November 17, 2010 New Version 17/11/10GUIExtender now works correctly with embedded objects and tabs (thanks JohnOne for the initial bug reports and trancexx for the code to fix the object bug ).The object problem arose because there is no direct link between the ControlID returned by GUICtrlCreateObj and the original object. So I have introduced a new function for the user to tell AutoIt about the 2 values - the UDF then works its magic to make the link:_GUIExtender_Obj_Data($iCID, $oObj)$iCID = ControlID returned by GUICtrlCreateObj$iObj = Original object reference returned by ObjCreateThe tab problem occurred because internal TabItems are given a ControlID by AutoIt, but do not actually exist as separate copntrols as far as Windows is concerned. The UDF now ignores them and just works with the Tab container.A new example has been added to show the UDF in action with embedded IE and Explorer panes and a Tab control. The example also shows how to use a HotKey to action the sections. New UDF and new example are in the first post and attached zip. 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
eracross Posted November 17, 2010 Posted November 17, 2010 Wow great work melba23 and thanks for sharing it.
shanet Posted December 27, 2010 Posted December 27, 2010 (edited) BUG FIXMelba 23,I just tried this and it works beautifully, however when you use it on software with the option MustDeclareVars turned on, it errors. There are only two simple edits to be made to fix this (as far as I am aware).Edit lines 387 and 389 so both variables are declared under the local scope, just as they are in the previous part of the same if statement.That worked for me Otherwise, congratulations on this UDF, it is really well made.shanet Edited December 27, 2010 by shanet [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm
Moderators Melba23 Posted December 27, 2010 Author Moderators Posted December 27, 2010 shanet, Thank you for that. And to think I posted only yesterday about the dangers of declaring variables within conditional structures. I have amended the UDF to remove the error. If you look closely, you will see I have not followed your recommendations exactly to fix the problem, but I am sure you will also understand why - please ask if not. All, New UDF code in the first post and zip. 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
lsakizada Posted January 8, 2011 Posted January 8, 2011 Melba, I tried to implement the mode in the Yashied's TabSkin but its behave strange. The seconds sections remove the all main GUI except the title bar. I have no idea what cause it. Can you please see whats wrong? You need to get the BMP files from the following link (Yashid's TabSkin topic) My code modification is bellow: expandcollapse popup#Include <Constants.au3> #Include <GUIConstantsEx.au3> #Include <StaticConstants.au3> #Include <TabConstants.au3> #Include <WindowsConstants.au3> #Include <Array.au3> #region custom #Include "GUIExtender.au3" #endregion Dim $Pic[5] $hGUI = GUICreate('MyGUI', 800, 600) _GUIExtender_Init($hGUI) _GUIExtender_Section_Start(0, 360) GUICtrlCreatePic('img_bg.bmp', 0, 0, 800, 369) GUICtrlSetState(-1, $GUI_DISABLE) For $i = 0 To UBound($Pic)-1 $Pic[$i] = GUICtrlCreatePic(@ScriptDir & '\img_black.bmp', 10, 24 + 50 * $i, 162, 49) GUICtrlCreateLabel('Tabsheet ' & $i, 21, 40 + 50 * $i, 140, 18, $SS_CENTER) GUICtrlSetFont(-1, 11, 400, 0, 'Tahoma') GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetcolor(-1, 0xFFFFFF) Next $Tab = GUICtrlCreateTab(172 + 4, 10 + 4, 523 - 8, 349 - 8) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateTabItem('Tabsheet0') GUICtrlCreateEdit('', 200 , 28, 487, 313) GUICtrlCreateTabItem('Tabsheet 1') GUICtrlCreateButton('OK', 398, 319, 70, 23) GUICtrlCreateTabItem('Tabsheet 2') GUICtrlCreateTabItem('Tabsheet 3') GUICtrlCreateTabItem('Tabsheet 4') GUICtrlCreateTabItem('') _GUIExtender_Section_Action(2, "", "", 5, 350, 15, 15) ; Normal button _GUIExtender_Section_End() _GUIExtender_Section_Start(360, 600) GUICtrlCreateGroup(" 2 - Extendable ", 1, 371, 798, 220) _GUIExtender_Section_End() _GUIExtender_Section_Extend(2, True) GUISetState() $Item = -1 $Over = -1 While 1 $Info = GUIGetCursorInfo() If @error Then If $Over <> -1 Then GUICtrlSetImage($Pic[$Over], @ScriptDir & '\img_black.bmp') EndIf $Over = -1 Else $Index = _Index($Info[4]) If $Index <> $Over Then If $Over <> -1 Then GUICtrlSetImage($Pic[$Over], @ScriptDir & '\img_black.bmp') EndIf If ($Index <> -1) And ($Index <> $Item) Then GUICtrlSetImage($Pic[$Index], @ScriptDir & '\img_over.bmp') $Over = $Index Else $Over = -1 EndIf EndIf EndIf $Msg = GUIGetMsg() If $Item = -1 Then $Msg = $Pic[0] $Item = 1 EndIf Switch $Msg Case 0 ContinueLoop Case $GUI_EVENT_CLOSE Exit Case $Pic[0] To $Pic[UBound($Pic) - 1] If $Msg <> $Pic[$Item] Then GUICtrlSetImage($Pic[$Item], @ScriptDir & '\img_black.bmp') GUICtrlSetcolor($Pic[$Item] + 1, 0xFFFFFF) GUICtrlSetImage($Msg, @ScriptDir & '\img_white.bmp') GUICtrlSetcolor($Msg + 1, 0x313A42) $Item = _Index($Msg) GUICtrlSendMsg($Tab, $TCM_SETCURFOCUS, $Item, 0) $Over = -1 EndIf EndSwitch _GUIExtender_Action($Msg) WEnd Func _Index($CtrlID) For $i = 0 To UBound($Pic) - 1 If ($CtrlID = $Pic[$i]) Or ($CtrlID = $Pic[$i] + 1) Then Return $i EndIf Next Return -1 EndFunc ;==>_Index Be Green Now or Never (BGNN)!
Moderators Melba23 Posted January 8, 2011 Author Moderators Posted January 8, 2011 lsakizada,It was not behaving correctly because you had not put the correct vertical values into the _GUIExtender_Section_Start lines. The fully extended GUI looks like this:#----# 0 | | ; The tab part - 370 pixels deep | | | | #----# 370 | | ; The extendable part - 230 pixels deep | | #----# 600So you should use the following vertical values: _GUIExtender_Section_Start(0, 370) - the tab part_GUIExtender_Section_Start(370, 230) - the extendable part. Note that the value is the height of the section, not the whole GUI.You had: _GUIExtender_Section_Start(0, 360) - so the first section did not even cover the whole Tab part of the GUI_GUIExtender_Section_Start(360, 600) - so the second part thought it was 600 pixels deep. As a result, when you hid the extendable section it retracted 600 pixels - that is all the GUI - and so you were left with just the header bar. This script uses the correct values and works fine for me:expandcollapse popup#Include <Constants.au3> #Include <GUIConstantsEx.au3> #Include <StaticConstants.au3> #Include <TabConstants.au3> #Include <WindowsConstants.au3> #Include <Array.au3> #region custom #Include "GUIExtender.au3" #endregion Dim $Pic[5] $hGUI = GUICreate('MyGUI', 800, 600) _GUIExtender_Init($hGUI) _GUIExtender_Section_Start(0, 370) GUICtrlCreatePic('img_bg.bmp', 0, 0, 800, 369) GUICtrlSetState(-1, $GUI_DISABLE) For $i = 0 To UBound($Pic)-1 $Pic[$i] = GUICtrlCreatePic(@ScriptDir & '\img_black.bmp', 10, 24 + 50 * $i, 162, 49) GUICtrlCreateLabel('Tabsheet ' & $i, 21, 40 + 50 * $i, 140, 18, $SS_CENTER) GUICtrlSetFont(-1, 11, 400, 0, 'Tahoma') GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetcolor(-1, 0xFFFFFF) Next $Tab = GUICtrlCreateTab(172 + 4, 10 + 4, 523 - 8, 349 - 8) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateTabItem('Tabsheet0') GUICtrlCreateEdit('', 200 , 28, 487, 313) GUICtrlCreateTabItem('Tabsheet 1') GUICtrlCreateButton('OK', 398, 319, 70, 23) GUICtrlCreateTabItem('Tabsheet 2') GUICtrlCreateTabItem('Tabsheet 3') GUICtrlCreateTabItem('Tabsheet 4') GUICtrlCreateTabItem('') _GUIExtender_Section_Action(2, "", "", 5, 350, 15, 15) ; Normal button _GUIExtender_Section_End() _GUIExtender_Section_Start(370, 230) GUICtrlCreateGroup(" 2 - Extendable ", 5, 371, 790, 220) _GUIExtender_Section_End() _GUIExtender_Section_Extend(2, True) GUISetState() $Item = -1 $Over = -1 While 1 $Info = GUIGetCursorInfo() If @error Then If $Over <> -1 Then GUICtrlSetImage($Pic[$Over], @ScriptDir & '\img_black.bmp') EndIf $Over = -1 Else $Index = _Index($Info[4]) If $Index <> $Over Then If $Over <> -1 Then GUICtrlSetImage($Pic[$Over], @ScriptDir & '\img_black.bmp') EndIf If ($Index <> -1) And ($Index <> $Item) Then GUICtrlSetImage($Pic[$Index], @ScriptDir & '\img_over.bmp') $Over = $Index Else $Over = -1 EndIf EndIf EndIf $Msg = GUIGetMsg() If $Item = -1 Then $Msg = $Pic[0] $Item = 1 EndIf Switch $Msg Case 0 ContinueLoop Case $GUI_EVENT_CLOSE Exit Case $Pic[0] To $Pic[UBound($Pic) - 1] If $Msg <> $Pic[$Item] Then GUICtrlSetImage($Pic[$Item], @ScriptDir & '\img_black.bmp') GUICtrlSetcolor($Pic[$Item] + 1, 0xFFFFFF) GUICtrlSetImage($Msg, @ScriptDir & '\img_white.bmp') GUICtrlSetcolor($Msg + 1, 0x313A42) $Item = _Index($Msg) GUICtrlSendMsg($Tab, $TCM_SETCURFOCUS, $Item, 0) $Over = -1 EndIf EndSwitch _GUIExtender_Action($Msg) WEnd Func _Index($CtrlID) For $i = 0 To UBound($Pic) - 1 If ($CtrlID = $Pic[$i]) Or ($CtrlID = $Pic[$i] + 1) Then Return $i EndIf Next Return -1 EndFunc ;==>_IndexI hope it does for you too. 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
lsakizada Posted January 9, 2011 Posted January 9, 2011 Thanks melba. I was aware of that parameter but somehow I missed it Now that I can see the GUI I found that all top part is flickering heavily on extending it. I am trying to fix it but it's prety hard task I guess. I found the code bellow somewhere but Its works for resizing and not for extending the GUI. Any other method that you know? expandcollapse popup;;ANTIFLICKER START Global Const $WM_EXITSIZEMOVE = 0x0232 ;Global Const $WS_EX_COMPOSITED = 0x2000000 GUIRegisterMsg($WM_SIZING, "WM_SIZING") GUIRegisterMsg($WM_EXITSIZEMOVE, "WM_EXITSIZEMOVE") Global $g_IsResizing = False Func WM_SIZING($hWnd, $Msg, $wParam, $lParam) ; add $WS_EX_COMPOSITED to the extended window style #forceref $hWnd, $Msg, $wParam, $lParam Local $GUIStyle If Not $g_IsResizing Then ; resizing begins $GUIStyle = GUIGetStyle($hGUI) GUISetStyle(-1, BitOR($GUIStyle[1], $WS_EX_COMPOSITED), $hGUI) $g_IsResizing = True EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZING Func WM_EXITSIZEMOVE($hWnd, $Msg, $wParam, $lParam) ; reset the extended window style to previous values #forceref $hWnd, $Msg, $wParam, $lParam Local $GUIStyle If $g_IsResizing Then ; resizing ends $GUIStyle = GUIGetStyle($hGUI) GUISetStyle(-1, BitAND($GUIStyle[1], BitNOT($WS_EX_COMPOSITED)), $hGUI) ; GUICtrlSetState($hListView, $GUI_SHOW) ;_GUICtrlListView_EndUpdate($hListView) $g_IsResizing = False EndIf ;GUICtrlSetResizing($hCombo, $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT + $GUI_DOCKRIGHT) Return $GUI_RUNDEFMSG EndFunc ;==>WM_EXITSIZEMOVE ;;ANTIFLICKER END Be Green Now or Never (BGNN)!
Moderators Melba23 Posted January 9, 2011 Author Moderators Posted January 9, 2011 lsakizada,It flickers because the UDF hides and then redisplays all the controls while extending/retracting so that any movements are hidden from view. There are a lot of images in the tab part of the GUI so unfortunately it flickers quite badly.I know of no way to prevent that, sorry. 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
Raupi Posted January 9, 2011 Posted January 9, 2011 The Example FIle GUIExtender_Example_Object_Tab.au3, has an Error. Line 22 _IENavigate ($oIE, "http://www.autoitscript.com") The Var $oIE not exists. New Code: _IENavigate ($oIE_1, "http://www.autoitscript.com") fix the Problem.
Moderators Melba23 Posted January 9, 2011 Author Moderators Posted January 9, 2011 Raupi, Thank you for that. I have amended the code and zip in the first post. 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
shanet Posted January 9, 2011 Posted January 9, 2011 I have amended the UDF to remove the error. If you look closely, you will see I have not followed your recommendations exactly to fix the problem, but I am sure you will also understand why - please ask if not. Well, It has been a fair while since I looked at it and I can not remember what it was that we had to declare scopes for, so can you please tell me how you implemented this fix?Thanks Melba23 shanet [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm
Moderators Melba23 Posted January 9, 2011 Author Moderators Posted January 9, 2011 shanet, I set the variables in question to their most likely value before the conditional structure and then only amended them within the structure if required - that way they are always declared reagrdless of the conditional branch: Local $iAdjust_X = 0, $iAdjust_Y = 0 ; Variables declared here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< For $i = 1 To $aGUIExt_Section_Data[0][0] ; Is this section visible? If $aGUIExt_Section_Data[$i][2] > 0 Then ; Get current position of section anchor $aPos = ControlGetPos($aGUIExt_Section_Data[0][3], "", $aGUIExt_Section_Data[$i][3]) If $aGUIExt_Section_Data[0][1] Then ; Depending on orientation ; Determine required change in X position for section controls $iAdjust_X = $aPos[0] - $iNext_Coord ; Amended if required here <<<<<<<<<<<<<<<<< ; Determine if controls need to be moved back into the GUI If $aPos[1] > $iGUI_Fixed Then $iAdjust_Y = $iGUI_Fixed ; Amended if required here <<<<<<<<<<<<<<<<< Else ; Determine required change in Y position for section controls $iAdjust_Y = $aPos[1] - $iNext_Coord ; Amended if required here <<<<<<<<<<<<<<<<< ; Determine if controls need to be moved back into the GUI If $aPos[0] > $iGUI_Fixed Then $iAdjust_X = $iGUI_Fixed ; Amended if required here <<<<<<<<<<<<<<<<< EndIf Your solution of declaring the variables in both sections of the conditional structure is perfectly workable, but I felt that the solution above was a little more elegant - it also shortened the code. 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
Lupo73 Posted February 27, 2011 Posted February 27, 2011 (edited) I'm trying to implement this udf in a program, but an error (Subscript used with non-Array variable) at line 442 of GUIExtender.au3 makes crash it. The portion of the code where it is used is a window with some elements like input boxes and buttons. It uses 3 sections (1 static, 2 extendible, 3 static) and the error happens the second time I open that window. So the first time it works fine, but if I close the window and reopen it, the error stop the script. The code is a little complex, so it could be a problem connected to other functions. This is the function as-is (not testable, but may be useful to detect if I miss something to correctly implement your udf): expandcollapse popupFunc _Manage_Edit_GUI($mProfileName = -1, $mFileName = -1, $mFileNameExt = -1, $mInitialType = -1, $mDirectory = -1, $mHandle = -1, $mNewAssociation = 0, $mDroppedEvent = 0) Local $mEmptyDestination = "Empty-Destination" Local $mGUI, $mMsg, $mInput_Name, $mInput_Rule, $mButton_Rule, $mCombo_Type, $mButton_Type, $mInput_Directory, $mButton_Directory, $mSave, $mCancel Local $mInput_RuleData, $mCombo_TypeData, $mInput_NameRead, $mInput_DirectoryRead, $mMsgBox, $mFolder, $mDestination_Label Local $mTEMPFileNameExt, $mAssociationType, $mItem, $mChanged = 0 Local $mProfile = __IsProfile($mProfileName, 0) ; Get Array Of Current Profile. If $mFileName = -1 Then $mFileName = "" If $mFileNameExt = -1 Then $mFileNameExt = "" If $mInitialType = -1 Then $mInitialType = __Lang_Get('MOVE', 'Move') If $mDirectory = -1 Or $mDirectory = "" Then $mDirectory = @ScriptDir Local $mCurrentType = $mInitialType $mInput_RuleData = $mFileNameExt $mCombo_TypeData = __Lang_Get('MOVE', 'Move') & '|' & __Lang_Get('COPY', 'Copy') & '|' & __Lang_Get('COMPRESS', 'Compress') & '|' & __Lang_Get('EXTRACT', 'Extract') & '|' & __Lang_Get('DELETE', 'Delete') & '|' & __Lang_Get('OPEN_WITH', 'Open With') & '|' & __Lang_Get('EXCLUDE', 'Exclude') $mItem = "[" & __Lang_Get('PROFILE', 'Profile') & ": " & $mProfile[1] & "]" Select Case $mNewAssociation = 0 And $mDroppedEvent = 0 $mAssociationType = __Lang_Get('MANAGE_ASSOCIATION_EDIT', 'Edit Association') Case $mNewAssociation = 1 And $mDroppedEvent = 0 $mAssociationType = __Lang_Get('MANAGE_ASSOCIATION_NEW', 'New Association') Case $mNewAssociation = 1 And $mDroppedEvent = 1 $mAssociationType = __Lang_Get('MANAGE_ASSOCIATION_NEW', 'New Association') $mInput_RuleData = "**" If $mFileNameExt <> "0" Then $mInput_RuleData = "*." & $mFileNameExt ; $mFileNameExt = "0" If Loaded Item Is A Folder. EndSelect $mGUI = GUICreate($mAssociationType & " " & $mItem, 300, 330, -1, -1, -1, $WS_EX_TOOLWINDOW, __OnTop($mHandle)) _GUIExtender_Init($mGUI) ; Section 1 _GUIExtender_Section_Start(0, 180) GUICtrlCreateLabel(__Lang_Get('DESCRIPTION', 'Description') & ":", 10, 10, 160, 20) $mInput_Name = GUICtrlCreateInput($mFileName, 10, 31, 278, 20) GUICtrlSetTip($mInput_Name, __Lang_Get('MANAGE_EDIT_TIP_0', 'Choose a description for this association.')) GUICtrlCreateLabel(__Lang_Get('MANAGE_PATTERN_RULE', 'Pattern Rule') & ":", 10, 60 + 10, 160, 20) $mInput_Rule = GUICtrlCreateInput($mInput_RuleData, 10, 60 + 31, 200, 20) GUICtrlSetTip($mInput_Rule, __Lang_Get('MANAGE_EDIT_TIP_1', 'Write a pattern rule for this association.')) $mButton_Rule = GUICtrlCreateButton(__Lang_Get('INFO', 'Info'), 10 + 208, 60 + 30, 70, 22) GUICtrlCreateLabel(__Lang_Get('MANAGE_ACTION', 'Action') & ":", 10, 120 + 10, 160, 20) $mCombo_Type = GUICtrlCreateCombo("", 10, 120 + 31, 200, 24, 0x0003) ; $mButton_Type = GUICtrlCreateButton(__Lang_Get('INFO', 'Info'), 10 + 208, 120 + 30, 70, 22) _GUIExtender_Section_Action(2, "Less", "More", 10 + 208, 120 + 30, 70, 22, 1) _GUIExtender_Section_End() ; Section 2 _GUIExtender_Section_Start(180, 40) GUICtrlCreateButton(__Lang_Get('INFO', 'Info'), 10, 180, 70, 22) ; <<<<<<<<<<<<<<<<< test _GUIExtender_Section_End() ; Section 3 _GUIExtender_Section_Start(220, 100) $mDestination_Label = GUICtrlCreateLabel(__Lang_Get('MANAGE_DESTINATION_FOLDER', 'Destination Folder') & ":", 10, 220 + 10, 160, 20) $mInput_Directory = GUICtrlCreateInput($mDirectory, 10, 220 + 31, 200, 20) GUICtrlSetTip($mInput_Directory, __Lang_Get('MANAGE_EDIT_TIP_2', 'As destination are supported both absolute and relative paths.')) $mButton_Directory = GUICtrlCreateButton(__Lang_Get('SEARCH', 'Search'), 10 + 208, 220 + 30, 70, 22) If $mCurrentType == __Lang_Get('EXCLUDE', 'Exclude') Or $mCurrentType == __Lang_Get('DELETE', 'Delete') Then GUICtrlSetData($mInput_Directory, __Lang_Get('EMPTY', 'Empty')) GUICtrlSetState($mInput_Directory, $GUI_DISABLE) GUICtrlSetState($mButton_Directory, $GUI_DISABLE) ElseIf $mCurrentType == __Lang_Get('OPEN_WITH', 'Open With') Then GUICtrlSetData($mDestination_Label, __Lang_Get('MANAGE_DESTINATION_PROGRAM', 'Destination Program') & ":") EndIf GUICtrlSetData($mCombo_Type, $mCombo_TypeData, $mCurrentType) $mSave = GUICtrlCreateButton("&" & __Lang_Get('SAVE', 'Save'), 150 - 20 - 76, 290, 76, 26) GUICtrlSetState($mSave, 144) ; Disable Save Button Initially. $mCancel = GUICtrlCreateButton("&" & __Lang_Get('CANCEL', 'Cancel'), 150 + 20, 290, 76, 26) GUICtrlSetState($mCancel, 576) _GUIExtender_Section_End() _GUIExtender_Section_Extend(0, False) GUISetState(@SW_SHOW) ControlClick($mGUI, "", $mInput_Name) While 1 __ReduceMemory() ; Reduce Memory Of DropIt. ; Enable/Disable Destination Input And Switch Folder/Program Label. If GUICtrlRead($mCombo_Type) <> $mCurrentType And _GUICtrlComboBox_GetDroppedState($mCombo_Type) = False Then $mCurrentType = GUICtrlRead($mCombo_Type) Switch $mCurrentType Case __Lang_Get('EXCLUDE', 'Exclude'), __Lang_Get('DELETE', 'Delete') GUICtrlSetState($mInput_Directory, $GUI_DISABLE) GUICtrlSetState($mButton_Directory, $GUI_DISABLE) If GUICtrlRead($mInput_Directory) == "" Then GUICtrlSetData($mInput_Directory, __Lang_Get('EMPTY', 'Empty')) Case Else GUICtrlSetState($mInput_Directory, $GUI_ENABLE) GUICtrlSetState($mButton_Directory, $GUI_ENABLE) If GUICtrlRead($mInput_Directory) == __Lang_Get('EMPTY', 'Empty') Then GUICtrlSetData($mInput_Directory, "") EndSwitch Switch $mCurrentType Case __Lang_Get('OPEN_WITH', 'Open With') GUICtrlSetData($mDestination_Label, __Lang_Get('MANAGE_DESTINATION_PROGRAM', 'Destination Program') & ":") Case Else GUICtrlSetData($mDestination_Label, __Lang_Get('MANAGE_DESTINATION_FOLDER', 'Destination Folder') & ":") EndSwitch EndIf ; Enable/Disable Save Button. If GUICtrlRead($mInput_Rule) <> "" And __StringIsValid(GUICtrlRead($mInput_Directory), "$|") And Not StringIsSpace(GUICtrlRead($mInput_Rule)) Then If GUICtrlGetState($mSave) > 80 Then GUICtrlSetState($mSave, 576) ; 80 = Normal; 144 = Disabled; 576 = Focused. If GUICtrlGetState($mCancel) = 512 Then GUICtrlSetState($mCancel, 80) ; 80 = Normal; 144 = Disabled; 576 = Focused. ElseIf GUICtrlRead($mInput_Rule) = "" Or Not __StringIsValid(GUICtrlRead($mInput_Directory), "$|") Or StringIsSpace(GUICtrlRead($mInput_Rule)) Then If GUICtrlGetState($mSave) = 80 Then GUICtrlSetState($mSave, 144) ; 80 = Normal; 144 = Disabled; 576 = Focused. If GUICtrlGetState($mCancel) = 80 Then GUICtrlSetState($mCancel, 512) ; 80 = Normal; 144 = Disabled; 576 = Focused. EndIf $mMsg = GUIGetMsg() Switch $mMsg Case $GUI_EVENT_CLOSE, $mCancel SetError(1, 1, 0) ExitLoop Case $mSave $mInput_NameRead = GUICtrlRead($mInput_Name) $mInput_DirectoryRead = GUICtrlRead($mInput_Directory) $mFileNameExt = StringLower(GUICtrlRead($mInput_Rule)) If $mCurrentType <> __Lang_Get('EXCLUDE', 'Exclude') And $mCurrentType <> __Lang_Get('DELETE', 'Delete') And Not __FilePathIsValid(_WinAPI_ExpandEnvironmentStrings($mInput_DirectoryRead)) And Not StringInStr($mInput_DirectoryRead, "%File%") Then MsgBox(0x30, __Lang_Get('MANAGE_EDIT_MSGBOX_0', 'Destination Error'), __Lang_Get('MANAGE_EDIT_MSGBOX_1', 'You must specify a valid destination.'), 0, __OnTop($mGUI)) ContinueLoop EndIf Switch $mCurrentType Case __Lang_Get('COPY', 'Copy') $mTEMPFileNameExt = $mFileNameExt & "$1" Case __Lang_Get('EXCLUDE', 'Exclude') $mTEMPFileNameExt = $mFileNameExt & "$2" $mInput_DirectoryRead = $mEmptyDestination Case __Lang_Get('COMPRESS', 'Compress') $mTEMPFileNameExt = $mFileNameExt & "$3" Case __Lang_Get('EXTRACT', 'Extract') $mTEMPFileNameExt = $mFileNameExt & "$4" If StringInStr($mFileNameExt, "**") Then MsgBox(0x30, __Lang_Get('MANAGE_EDIT_MSGBOX_4', 'Pattern Error'), __Lang_Get('MANAGE_EDIT_MSGBOX_11', 'You cannot use this action for folders.'), 0, __OnTop($mGUI)) ContinueLoop EndIf Case __Lang_Get('OPEN_WITH', 'Open With') $mTEMPFileNameExt = $mFileNameExt & "$5" If Not __IsSupported($mInput_DirectoryRead, "bat;cmd;com;exe;pif") Or StringInStr($mInput_DirectoryRead, "DropIt.exe") Then ; DropIt.exe Is Excluded To Avoid A Loop. MsgBox(0x30, __Lang_Get('MANAGE_EDIT_MSGBOX_0', 'Destination Error'), __Lang_Get('MANAGE_EDIT_MSGBOX_1', 'You must specify a valid destination.'), 0, __OnTop($mGUI)) ContinueLoop EndIf Case __Lang_Get('DELETE', 'Delete') $mTEMPFileNameExt = $mFileNameExt & "$6" $mInput_DirectoryRead = $mEmptyDestination Case Else ; Move $mTEMPFileNameExt = $mFileNameExt & "$0" EndSwitch If StringInStr($mFileNameExt, "*") And Not StringInStr(StringRight($mFileNameExt, 2), "$") And Not StringInStr($mFileNameExt, "|") And Not StringInStr($mInput_DirectoryRead, "|") And Not StringInStr($mInput_NameRead, "|") Then $mMsgBox = 6 If IniRead($mProfile[0], "Patterns", $mTEMPFileNameExt, "0") <> "0" Then If $mFileNameExt <> $mInput_RuleData Then $mMsgBox = MsgBox(0x04, __Lang_Get('MANAGE_EDIT_MSGBOX_2', 'Replace association'), __Lang_Get('MANAGE_EDIT_MSGBOX_3', 'This pattern rule already exists. Do you want to replace it?'), 0, __OnTop()) If $mMsgBox = 6 Then IniDelete($mProfile[0], "Patterns", $mTEMPFileNameExt) EndIf If $mMsgBox = 6 Then If $mNewAssociation = 0 Then Switch $mInitialType Case __Lang_Get('COPY', 'Copy') $mInitialType = "$1" Case __Lang_Get('EXCLUDE', 'Exclude') $mInitialType = "$2" Case __Lang_Get('COMPRESS', 'Compress') $mInitialType = "$3" Case __Lang_Get('EXTRACT', 'Extract') $mInitialType = "$4" Case __Lang_Get('OPEN_WITH', 'Open With') $mInitialType = "$5" Case __Lang_Get('DELETE', 'Delete') $mInitialType = "$6" Case Else ; Move $mInitialType = "$0" EndSwitch IniDelete($mProfile[0], "Patterns", $mInput_RuleData & $mInitialType) EndIf If $mInput_NameRead <> "" Then $mInput_DirectoryRead &= "|" & $mInput_NameRead IniWrite($mProfile[0], "Patterns", $mTEMPFileNameExt, $mInput_DirectoryRead) $mChanged = 1 ExitLoop EndIf Else MsgBox(0x30, __Lang_Get('MANAGE_EDIT_MSGBOX_4', 'Pattern Error'), __Lang_Get('MANAGE_EDIT_MSGBOX_5', 'You have to insert a correct pattern ("$", "?", "|" characters cannot be used)'), 0, __OnTop()) EndIf Case $mButton_Rule MsgBox(0, __Lang_Get('MANAGE_EDIT_MSGBOX_6', 'Supported Rules'), __Lang_Get('MANAGE_EDIT_MSGBOX_7', 'Examples of supported pattern rules for files: @LF *.jpg = all files with "jpg" extension @LF penguin.* = all files named "penguin" @LF penguin*.* = all files that begin with "penguin" @LF *penguin* = all files that contain "penguin" @LF @LF Examples of supported pattern rules for folders: @LF robot** = all folders that begin with "robot" @LF **robot = all folders that end with "robot" @LF **robot** = all folders that contain "robot" @LF @LF Separate several rules in a pattern with ";" to @LF create multi-rule patterns (eg: *.jpg;*.png ).'), 0, __OnTop()) ;Case $mButton_Type ;MsgBox(0, __Lang_Get('MANAGE_EDIT_MSGBOX_8', 'Action'), __Lang_Get('MANAGE_EDIT_MSGBOX_9', 'You can select the mode of processing files that match with this pattern.'), 0, __OnTop()) Case $mButton_Directory If $mCurrentType <> __Lang_Get('OPEN_WITH', 'Open With') Then $mFolder = FileSelectFolder(__Lang_Get('MANAGE_DESTINATION_FOLDER_SELECT', 'Select a destination folder:'), "", 3, "", $mGUI) If StringRight($mFolder, 1) = "\" Then $mFolder = StringTrimRight($mFolder, 1) Else $mFolder = FileOpenDialog(__Lang_Get('MANAGE_DESTINATION_PROGRAM_SELECT', 'Select a destination program:'), @ScriptDir, __Lang_Get('MANAGE_EDIT_MSGBOX_10', 'Executable or Script') & " (*.bat;*.cmd;*.com;*.exe;*.pif)", 1, "", $mGUI) If @error Then $mFolder = "" EndIf If $mFolder <> "" Then GUICtrlSetData($mInput_Directory, $mFolder) EndSwitch _GUIExtender_Action($mMsg) ; Check for click on Action control <<<<<<<<<< WEnd GUIDelete($mGUI) If $mChanged = 1 Then Return $mChanged Return SetError(1, 1, 0) EndFunc ;==>_Manage_Edit_GUI Edited February 27, 2011 by Lupo73 SFTPEx, AutoCompleteInput, _DateTimeStandard(), _ImageWriteResize(), _GUIGraduallyHide(): some AutoIt functions. Lupo PenSuite: all-in-one and completely free selection of portable programs and games. DropIt: a personal assistant to automatically manage your files. ArcThemALL!: application to multi-archive your files and folders.
Lupo73 Posted February 27, 2011 Posted February 27, 2011 I have replied the bug in a simple code, with a child window, created starting from your GUIExtender_Example_Loop: expandcollapse popup#include <GUIConstantsEx.au3> #include "GUIExtender.au3" _Test() Func _Test() $hGUI = GUICreate("Test", 300, 390) $Button = GUICtrlCreateButton("Test", 10, 20, 70, 22) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $Button _Test2() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Func _Test2() $hGUI = GUICreate("Test", 300, 390) _GUIExtender_Init($hGUI) _GUIExtender_Section_Start(0, 60) GUICtrlCreateGroup(" 1 - Static ", 10, 10, 280, 50) _GUIExtender_Section_Action(2, "", "", 270, 40, 15, 15) ; Normal button _GUIExtender_Section_End() _GUIExtender_Section_Start(60, 110) GUICtrlCreateGroup(" 2 - Extendable ", 10, 70, 280, 100) _GUIExtender_Section_End() _GUIExtender_Section_Start(170, 60) GUICtrlCreateGroup(" 3 - Static", 10, 180, 280, 50) _GUIExtender_Section_Action(4, "Close 4", "Open 4", 225, 195, 60, 20, 1) ; Push button _GUIExtender_Section_End() _GUIExtender_Section_Start(230, 60) GUICtrlCreateGroup(" 4 - Extendable ", 10, 240, 280, 50) _GUIExtender_Section_End() _GUIExtender_Section_Start(290, 90) GUICtrlCreateGroup(" 5 - Static", 10, 300, 280, 80) _GUIExtender_Section_Action(0, "Close All", "Open All", 20, 340, 60, 20) ; Normal button _GUIExtender_Section_End() GUICtrlCreateGroup("", -99, -99, 1, 1) _GUIExtender_Section_Extend(4, False) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch _GUIExtender_Action($iMsg) ; Check for click on Action control WEnd GUIDelete($hGUI) EndFunc SFTPEx, AutoCompleteInput, _DateTimeStandard(), _ImageWriteResize(), _GUIGraduallyHide(): some AutoIt functions. Lupo PenSuite: all-in-one and completely free selection of portable programs and games. DropIt: a personal assistant to automatically manage your files. ArcThemALL!: application to multi-archive your files and folders.
Recommended Posts