kylomas Posted November 29, 2014 Share Posted November 29, 2014 (edited) Does anyone have any ideas on how to maintain positioning of controls for multi-line tabs? The following is the best I could come up with but it seems entirely cumbersome. expandcollapse popup#include <TabConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <array.au3> #include <GuiTab.au3> #AutoIt3Wrapper_Add_Constants=n local $gui010 = guicreate('',500,500) local $lbl010 = guictrlcreatelabel('',20,30,200,20,$ss_sunken) local $inp010 = guictrlcreateinput('',20,60,100,20) local $btn010 = guictrlcreatebutton('Create Tab',20,450,70,20) local $btn020 = guictrlcreatebutton('Delete Tab',120,450,70,20) local $tab010 = guictrlcreatetab(0,0,500,400,$TCS_MULTILINE) guictrlcreatetabitem('Tab1') guictrlsetpos($lbl010,_GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[0]+20,_GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[1]+20) guictrlsetpos($inp010,_GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[0]+20,_GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[1]+60) guisetstate() local $idx = 1 while 1 switch guigetmsg() case $gui_event_close Exit case $btn010 guictrlcreatetabitem('Tab' & $idx + 1) guictrlcreatetabitem('') $idx += 1 guictrlsetpos($lbl010,_GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[0]+20,_GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[1]+20) guictrlsetpos($inp010,_GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[0]+20,_GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[1]+60) if _GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[3] - _GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[1] < 90 then _ guictrlsetstate($btn010,$gui_disable) case $lbl010 ConsoleWrite('clicked label in tab item ' & guictrlread($tab010) + 1 & @CRLF) case $btn020 guictrldelete(guictrlread($tab010,1)) if $idx > 0 then $idx -= 1 guictrlsetpos($lbl010,_GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[0]+20,_GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[1]+20) guictrlsetpos($inp010,_GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[0]+20,_GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[1]+60) if _GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[3] - _GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($tab010))[1] > 90 then _ guictrlsetstate($btn010,$gui_enable) EndSwitch WEnd I want all of the controls to participate in every tab (sort of like a template). kylomas edit: clarity The controls are created outside of tabitem definitions so that they appears on every tab. Edited November 29, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
LarsJ Posted November 29, 2014 Share Posted November 29, 2014 Create the controls in a child window, and place the window on top of the tab. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
kylomas Posted November 29, 2014 Author Share Posted November 29, 2014 LarsJ, Thank you for your response. Let me explain the problem a little more clearly. With each row of tabs the tab size decreases requiring the controls to move. Child windows have exactly the same problem. The controls are created outside of tabitem definitions so that they appear on every tab. The problem is keeping the controls lined up relative to each other. In the code snippet that I posted you can see that I test for a minimum tab size and disable the tab button when that is exceeded. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
LarsJ Posted November 29, 2014 Share Posted November 29, 2014 (edited) Yes, but you only have to reposition the child window, not all the controls. When the child window is moved one tab line down, all controls on this child window is also moved one tab line down. And there is no issue about lining up the controls.Edit: Last sentence. Edited November 29, 2014 by LarsJ Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted November 29, 2014 Moderators Solution Share Posted November 29, 2014 kylomas,I see LarsJ and I had the same idea: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GuiTab.au3> #include <WinAPI.au3> Opt("GUIResizeMode", $GUI_DOCKALL) $hGUI_Main = GUICreate("Test", 500, 500) $cButton_1 = GUICtrlCreateButton('Create Tab', 20, 450, 70, 20) $cButton_2 = GUICtrlCreateButton('Delete Tab', 120, 450, 70, 20) $cTab = GUICtrlCreateTab(0, 0, 500, 400, $TCS_MULTILINE) GUICtrlCreateTabItem('Tab_0') GUICtrlCreateTabItem('') GUISetState() $hGUI_Child = GUICreate("", 500, 400, 0, 0, $WS_POPUP, BitOr($WS_EX_MDICHILD, $WS_EX_LAYERED), $hGUI_Main) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($hGUI_Child, 0xABCDEF, 250) $cButton_3 = GUICtrlCreateButton('Test', 20, 30, 200, 20, $ss_sunken) $cInput = GUICtrlCreateInput('', 20, 60, 100, 20) GUISetState() GUISwitch($hGUI_Main) $iTabY = -1 _CheckTab() $iCount = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_3 ConsoleWrite('clicked button in tab item ' & GUICtrlRead($cTab) & @CRLF) Case $cButton_1 $iCount += 1 GUICtrlCreateTabItem('Tab_' & $iCount) GUICtrlCreateTabItem('') _CheckTab() Case $cButton_2 GUICtrlDelete(GUICtrlRead($cTab, 1)) _CheckTab() EndSwitch WEnd Func _CheckTab() $aTabRect = _GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($cTab)) If $aTabRect[1] <> $iTabY And $aTabRect[3] - $aTabRect[1] > 100 Then $tPoint = DllStructCreate("int X;int Y") DllStructSetData($tPoint, "X", $aTabRect[0]) DllStructSetData($tPoint, "Y", $aTabRect[1]) _WinAPI_ClientToScreen($hGUI_Main, $tPoint) $iX = DllStructGetData($tPoint, "X") $iY = DllStructGetData($tPoint, "Y") WinMove($hGUI_Child, "", $iX, $iY, $aTabRect[2] - $aTabRect[0], $aTabRect[3] - $aTabRect[1]) $iTabY = $aTabRect[1] EndIf EndFuncM23 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...
kylomas Posted November 29, 2014 Author Share Posted November 29, 2014 (edited) Thank you, gentlemen, I see it now... @LarsJ - If I knew how to include you in the "mark solved" deal I would. You gave me the answer and I was too thick to see it. Edited November 29, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
LarsJ Posted November 29, 2014 Share Posted November 29, 2014 Good that Melba23 got the idea done evident. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions 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