gseller Posted May 30, 2007 Posted May 30, 2007 (edited) Hey All, I wanted to post my first contribution. This will create Tabs in a GUI from the sections in an ini file. I hope this will be of use to someone. I searched all over and could not find anything on it. I did get some ideas and thank you to masonje found here: Dynamic Button Creation... Thank You masonjeHere is the file to try out DynamicTabsFromINI.au3Feedback would be Greatly Apreciated...expandcollapse popup#include <GUIConstants.au3> $iniFile = @ScriptDir & "\IP.ini";Reads ini file in general $iniSections = IniReadSectionNames($iniFile);Reads ini section names for tabs $seH = "5";horizontal positioning of each section in ini file $seL = "5";vertical positioning of each section in ini file ;Creating the GUI $GUIForm = GUICreate("GUI Name", 633, 447, 193, 115) $Group1 = GUICtrlCreateGroup("Your Group Box", 16, 16, 601, 417, -1, $WS_EX_TRANSPARENT) $Tab1 = GUICtrlCreateTab(25, 48, 583, 377) GUICtrlSetState(-1,$GUI_SHOW) GUICtrlCreateTabItem("") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.");Shows error if there is no ini file Else For $i = 1 To $iniSections[0];Setting up the dynamic tabs if $iniSections[$i] <> "Setup" then $tabName = $iniSections[$i] GUICtrlCreateTab($tabName, $seH + 15, $seL * 110,$WS_MAXIMIZE,$WS_EX_TRANSPARENT ) $tab0=GUICtrlCreateTabitem ($tabName) EndIf Next EndIf GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEndHere is an example ini[section 1] swt1=123.456.789.100 swt1=123.456.789.101 swt1=123.456.789.102 swt1=123.456.789.103 [section 2] swt1=123.456.789.100 swt1=123.456.789.101 swt1=123.456.789.102 swt1=123.456.789.103 [section 3] swt1=123.456.789.100 swt1=123.456.789.101 swt1=123.456.789.102 swt1=123.456.789.103 Edited June 1, 2007 by gesller
JohnBailey Posted September 13, 2007 Posted September 13, 2007 I think the idea is cool In fact, I bet I could use this in a few places. A decision is a powerful thing
JohnBailey Posted September 14, 2007 Posted September 14, 2007 (edited) Haha Gesller, I got a bit carried away expandcollapse popup; Original http://www.autoitscript.com/forum/index.php?showtopic=46805 ; Additions by JohnBailey (don't blame gesller for dumb ideas) #include <GUIConstants.au3> ;#include <Array.au3>; here for testing purposes Global $iniFile = FileOpenDialog('Open INI file',@ScriptDir,'INI (*.ini)'); Pick the Ini If @error Then Exit Endif ; $iniFile = @ScriptDir & "\IP.ini";Reads ini file in general $iniSections = IniReadSectionNames($iniFile);Reads ini section names for tabs $seH = "5";horizontal positioning of each section in ini file $seL = "5";vertical positioning of each section in ini file ;Creating the GUI $GUIForm = GUICreate("GUI Name", 633, 447, 193, 115) $Group1 = GUICtrlCreateGroup("Your Group Box", 16, 16, 601, 417, -1, $WS_EX_TRANSPARENT) $Tab1 = GUICtrlCreateTab(25, 48, 583, 377) GUICtrlSetState(-1,$GUI_SHOW) GUICtrlCreateTabItem("") GUICtrlCreateGroup("", -99, -99, 1, 1) If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.");Shows error if there is no ini file Else For $i = 1 To $iniSections[0];Setting up the dynamic tabs If $iniSections[$i] <> "Setup" then $tabName = $iniSections[$i] GUICtrlCreateTab($tabName, $seH + 15, $seL * 110,$WS_MAXIMIZE,$WS_EX_TRANSPARENT ) Local $tab0=GUICtrlCreateTabitem ($tabName) Local $iniReadSection2DArray = IniReadSection ($iniFile,$iniSections[$i]) Local $2DArraySize = $iniReadSection2DArray[0][0] Local $a = GUICtrlCreateListView("Element|Value",150,100,300,300) Assign('LV_'&$i,$a,1); Allows this ListView to be referenced after the loop(s) For $x = 1 to $2DArraySize GUICtrlCreateListViewItem($iniReadSection2DArray[$x][0]&'|'&$iniReadSection2DArray[$x][1],Eval('LV_'&$i)) Next EndIf Next EndIf GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd example ini [section 1] swt1=123.456.789.100 swt1=123.456.789.101 swt1=123.456.789.102 swt1=123.456.789.103 [section 2] swt2=123.456.789.104 swt2=123.456.789.105 swt2=123.456.789.106 swt2=123.456.789.107 [section 3] User43=123.456.789.108 User85=123.456.789.109 Manuel=123.456.789.110 Marcus=123.456.789.111 Edited September 14, 2007 by JohnBailey A decision is a powerful thing
GaryFrost Posted October 26, 2007 Posted October 26, 2007 line is incorrect and not needed: GUICtrlCreateTab($tabName, $seH + 15, $seL * 110,$WS_MAXIMIZE,$WS_EX_TRANSPARENT ) SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Michel Claveau Posted October 26, 2007 Posted October 26, 2007 Dynamic Tab Creation...Well... Well...And, for dynamic delete? How-to?
gseller Posted November 30, 2007 Author Posted November 30, 2007 Nice JohnBailey.. Just seen your post.. cool I like it...
GBMacMan Posted November 3, 2008 Posted November 3, 2008 Looks like its been a year or so since this got noticed. I like the idea. Do you have a screen shot of it running. I don't think its compatible with the current version. I got the errors below. Can this be turned into an editor as well. I have an application in mind. Your help could jump start this for me. Thanks
James Posted November 3, 2008 Posted November 3, 2008 Just missing some constants. expandcollapse popup#include <GUIConstants.au3> #include <WindowsConstants.au3> $iniFile = @ScriptDir & "\IP.ini";Reads ini file in general $iniSections = IniReadSectionNames($iniFile);Reads ini section names for tabs $seH = "5";horizontal positioning of each section in ini file $seL = "5";vertical positioning of each section in ini file ;Creating the GUI $GUIForm = GUICreate("GUI Name", 633, 447, 193, 115) $Group1 = GUICtrlCreateGroup("Your Group Box", 16, 16, 601, 417, -1, $WS_EX_TRANSPARENT) $Tab1 = GUICtrlCreateTab(25, 48, 583, 377) GUICtrlSetState(-1, $GUI_SHOW) GUICtrlCreateTabItem("") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.");Shows error if there is no ini file Else For $i = 1 To $iniSections[0];Setting up the dynamic tabs If $iniSections[$i] <> "Setup" Then $tabName = $iniSections[$i] GUICtrlCreateTab($tabName, $seH + 15, $seL * 110, $WS_MAXIMIZE, $WS_EX_TRANSPARENT) $tab0 = GUICtrlCreateTabItem($tabName) EndIf Next EndIf GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
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