Hi !
I'm working on a UDF that can show and hide group, and it's works very well when there is no GUI resize.
But when I set a resize i have some trouble effect, two to be exact.
When a group is "hide" and all other are show (or the opposite one is "open" and others are "hide") I have this effects :
1. The group lose width, if you compare with others...
2. The button with which you can hide or show the group moves strangely relative to others...
Maybe an image will be more explicit :
Image may be NSFW.
Clik here to view.
Example :
Spoiler
AutoIt
#include "HideAndShow.au3" #include <GuiConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> global $GetPos Global $iGrpStyle = $GUI_DOCKHEIGHT + $GUI_DOCKTOP + $GUI_DOCKLEFT Global $iIcoStyle = $GUI_DOCKHEIGHT + $GUI_DOCKTOP _Exemple() func _Exemple() Global $Form1 = GUICreate("Example", 600, 600, 0, 0,BitOR($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX, $ws_MAXIMIZEBOX)) GUISetState(@SW_SHOW) _HS_Start($Form1) Global $hGrpEV = _HS_GroupOpen("Titre du group", 5, 5 , 515, 150, $iGrpStyle, $iIcoStyle) $hListView = GUICtrlCreateListView("wd", 12, 20, 500, 125) GUICtrlSetResizing(-1,$GUI_DOCKHEIGHT + $GUI_DOCKTOP) _HS_GroupClose() Global $hGrpEV2 = _HS_GroupOpen("Titre du group", 5, 160 , 515, 150,$iGrpStyle,$iIcoStyle) GUICtrlCreateLabel("TEST", 15, 185) GUICtrlSetResizing(-1,$GUI_DOCKHEIGHT + $GUI_DOCKTOP) GUICtrlCreateProgress(40,210,150,15) GUICtrlSetResizing(-1,$GUI_DOCKHEIGHT + $GUI_DOCKTOP) _HS_GroupClose() Global $hGrpEV3 = _HS_GroupOpen("Titre du group", 5, 315, 515, 200,$iGrpStyle,$iIcoStyle) GUICtrlCreateButton("Button", 10, 475, 75, 25) GUICtrlSetResizing(-1,$GUI_DOCKHEIGHT + $GUI_DOCKTOP) GUICtrlCreateCheckbox("CheckBox", 100, 475, 75, 25) GUICtrlSetResizing(-1,$GUI_DOCKHEIGHT + $GUI_DOCKTOP) $hListView3 = GUICtrlCreateListView("test|test", 12, 330, 500, 125) GUICtrlSetResizing(-1,$GUI_DOCKHEIGHT + $GUI_DOCKTOP) _HS_GroupClose() GUICtrlCreateButton("Moving With Groups", 5, 550, 120, 20) _HS_Stop() $GetPos = GUICtrlCreateButton("NoMove", 200, 550, 50, 20) EndFunc While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit case $hGrpEV _HS_ActiveGroup($hGrpEV) case $hGrpEV2 _HS_ActiveGroup($hGrpEV2) case $hGrpEV3 _HS_ActiveGroup($hGrpEV3) case $GetPos $test = ControlGetPos($aHS_AllGroups[0][2], "", $aHS_AllGroups[InputBox("id","id")][0]) _ArrayDisplay($test) EndSwitch WEnd
UDF :
Spoiler
AutoIt
; #INDEX# ============================================================================================================ ; Title .........: HideAndShow ; AutoIt Version : 3.3 + ; Language ......: Eng ; Description ...: Allow user to create group with hide/show function. ; Remarks .......: ; Version .......: 0.1 (TEST) ; Author ........: M4n0x (20 july 2013) ; ==================================================================================================================== ; #INCLUDES# ========================================================================================================= #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> ; #GLOBAL VARIABLES# ================================================================================================= ; Array to save groups and other details about the main gui and number of groups. Global $aHS_AllGroups[1][8] ; #CURRENT# ========================================================================================================== ; _HS_GroupStart: Save the parent gui ; _HS_GroupOpen: create a group and save position info to an array ; _HS_GroupClose: Close the group and save last control id ; _HS_ActiveGroup: Main Function allow to use fonction hide and show. ; _HS_Stop: Stop deplacement of controls after this function. ; ==================================================================================================================== ; #INTERNAL_USE_ONLY#================================================================================================= ; _HS_ControlUP: Move up all controls id between the group and HS_Stop ; _HS_ControlDown: Move down all controls id between the group and HS_Stop ; ==================================================================================================================== ; #FUNCTION# ========================================================================================================= ; Name...........: _HS_Start ; Description ...: save GUI where groups are created ; Syntax.........: _HS_Start($hWnd) ; Parameters ....: $hWnd - Handle GUI where groups will be created ; Requirement(s).: v3.3 + ;===================================================================================================================== Func _HS_Start($hWnd) $aHS_AllGroups[0][2] = $hWnd EndFunc ;==>_HS_Start ; #FUNCTION# ========================================================================================================= ; Name...........: _HS_GroupOpen ; Description ...: Create a group and save informations into an global array ; Syntax.........: _HS_GroupOpen($sName, $iLeft, $iTop, $iWidth, $iHeight [, $iStyle = $GUI_DOCKHEIGHT + $GUI_DOCKTOP [, $iStyleIco = -1]]) ; Parameters ....: $sName - label of the groupe ; $iLeft - Left position ; $iTop - Top position ; $iWidth - Width of the group ; $iHeight - Heigth of the group ; $iStyle - Set resize parameter on case of a gui with $WS_SIZEBOX (for the groupe only, not the controls in it) ; $iStyleIco - Define resizing style for the Ico (button) for switching between hide and show ; Requirement(s).: v3.3 + ;===================================================================================================================== Func _HS_GroupOpen($sName, $iLeft, $iTop, $iWidth, $iHeight, $iStyle = -1, $iStyleIco = -1) Local $iCurrID = UBound($aHS_AllGroups) $aHS_AllGroups[0][0] = $iCurrID ; Le Total de groupe ReDim $aHS_AllGroups[$iCurrID + 1][8] $aHS_AllGroups[$iCurrID][0] = GUICtrlCreateGroup($sName, $iLeft, $iTop, $iWidth, $iHeight) if $iStyle <> -1 then GuiCtrlSetResizing(-1, $iStyle) $aHS_AllGroups[$iCurrID][1] = $iLeft $aHS_AllGroups[$iCurrID][2] = $iTop $aHS_AllGroups[$iCurrID][3] = $iWidth $aHS_AllGroups[$iCurrID][4] = $iHeight $aHS_AllGroups[$iCurrID][6] = True $aHS_AllGroups[$iCurrID][7] = GUICtrlCreateButton("", $iWidth +5, $iTop + 5, 19, 19, $BS_ICON) if $iStyleIco <> -1 then GuiCtrlSetResizing(-1, $iStyleIco) GUICtrlSetImage($aHS_AllGroups[$iCurrID][7], "Shell32.dll", -247, 0) Return $aHS_AllGroups[$iCurrID][7] EndFunc ;==>_HS_GroupOpen ; #FUNCTION# ========================================================================================================= ; Name...........: _HS_GroupClose ; Description ...: Close the group and save informations in the global array ; Syntax.........: _HS_GroupClose() ; Parameters ....: NoParam ; Requirement(s).: v3.3 + ;===================================================================================================================== Func _HS_GroupClose() $aHS_AllGroups[UBound($aHS_AllGroups) - 1][5] = GUICtrlCreateGroup("", -99, -99, 1, 1) GuiCtrlSetResizing(-1, $GUI_DOCKALL) EndFunc ;==>_HS_GroupClose ; #FUNCTION# ========================================================================================================= ; Name...........: _HS_ActiveGroup ; Description ...: Retract the group in parameter and moves all controls created after the group until _HS_Stop() ; Syntax.........: _HS_GroupOpen($sName, $iLeft, $iTop, $iWidth, $iHeight) ; Parameters ....: $iCtrlID - handle the image id control to use hide/show function, this paramater is saved in the global ; array, with this, the udf can retrieve the group id by searching in the global array. ; Requirement(s).: v3.3 + ;===================================================================================================================== Func _HS_ActiveGroup($iCtrlID) Local $iCurrID = UBound($aHS_AllGroups) ; retrieve the group For $id = 0 To $iCurrID - 1 If $iCtrlID = $aHS_AllGroups[$id][7] Then ExitLoop Next If $aHS_AllGroups[$id][6] Then GUICtrlSetPos($aHS_AllGroups[$id][0], Default, Default, Default, 30) ; hide all objects in the group For $i = $aHS_AllGroups[$id][0] + 1 To $aHS_AllGroups[$id][5] - 1 If $aHS_AllGroups[$id][7] = $i Then GUICtrlSetImage($aHS_AllGroups[$id][7], "shell32.dll", -248, 0) ContinueLoop EndIf GUICtrlSetState($i, $GUI_HIDE) Next _HS_ControlUP($id) ;Switch to know if is already retracted ( false = not retracted ) $aHS_AllGroups[$id][6] = False Else _HS_ControlDown($id) GUICtrlSetPos($aHS_AllGroups[$id][0], Default, Default, Default, $aHS_AllGroups[$id][4]) ; show all objects in the group For $i = $aHS_AllGroups[$id][0] + 1 To $aHS_AllGroups[$id][5] - 1 If $aHS_AllGroups[$id][7] = $i Then GUICtrlSetImage($aHS_AllGroups[$id][7], "shell32.dll", -247, 0) ContinueLoop EndIf GUICtrlSetState($i, $GUI_SHOW) Next ;Switch to know if is already retracted ( true = not retracted ) $aHS_AllGroups[$id][6] = True EndIf EndFunc ;==>_HS_ActiveGroup ; #INTERNAL_USE_ONLY# ========================================================================================================= ; Name...........: _HS_ControlUP ; Description ...: Move up all controls id between the group and HS_Stop ;============================================================================================================================== Func _HS_ControlUP($id) For $i = $aHS_AllGroups[$id][5]+1 To $aHS_AllGroups[0][1] - 1 $test = ControlGetPos($aHS_AllGroups[0][2], "", $i) if $test[0] = -99 and $test[1] = -99 Then ContinueLoop GUICtrlSetPos($i, Default, ($test[1] - $aHS_AllGroups[$id][4]) + 30) Next EndFunc ;==>_HS_ControlUP ; #INTERNAL_USE_ONLY# ========================================================================================================= ; Name...........: _HS_ControlUP ; Description ...: Move down all controls id between the group and HS_Stop ;============================================================================================================================== Func _HS_ControlDown($id) For $i = $aHS_AllGroups[$id][5]+1 To $aHS_AllGroups[0][1] - 1 $test = ControlGetPos($aHS_AllGroups[0][2], "", $i) if $test[0] = -99 and $test[1] = -99 Then ContinueLoop GUICtrlSetPos($i, Default, ($test[1] + $aHS_AllGroups[$id][4]) - 30) Next EndFunc ;==>_HS_ControlDown ; #FUNCTION# ========================================================================================================= ; Name...........: _HS_Stop ; Description ...: Stored the last control id for moving the correct controls ; Syntax.........: _HS_Start() ; Parameters ....: No param ; Requirement(s).: v3.3 + ;===================================================================================================================== Func _HS_Stop() $aHS_AllGroups[0][1] = GUICtrlCreateDummy() EndFunc ;==>_HS_Stop
I must have missed something! ( something really stupid ^^)
Thanks for reading...