Sign in to follow this  
Followers 0
ghetek

INI Based Tab Creation

1 post in this topic

Hey guys!

I was sitting in bed with my girlfriend and going over chocolates that we have tried and liked from CocoBella. Naturally I decided to record our notes in INI form because it seemed convenient at the time:

Chocolate Notes.txt

[tried and disliked]
Vietnamese Cinnamon=Christopher Elbow
Ginger Heart=Recchiuti

[Tried and liked]
Rasberry=Christopher Elbow
Nougatelle=Michel Cluizel
Peanut Brittle=Christopher Elbow
Key Lime=Norman Love
Cookies and Cream=Normal Love
Peanut Butter and Jelly=Norman Love
Venezuela Dark=Christopher Elbow

[Want to try]
Palet Frambois=Michel Cluizel
Mint Chocolate Chip=Norman Love
Rasberry Praline=Läderach
Tiramisu Truffle=Mary Chocolatier
New York Cheesecake=Norman Love
Passionfruit Truffle=Läderach
Strawberry Cup=Parlineur Van Coillie
Coco Bello Praline=Läderach
Vanilla Cupcake=Norman Love
Rose Caramel=Recchiuti
White Truffle=Läderach
Champignon=Marquis De Sevigne
Yuzu=Oriol Balaguer

Soon I decided that I need to have a pretty GUI to look at. I hated the idea of making a static number of tabs so I came up with this:

TabsByINI.au3

#include <GUIConstantsEx.au3>
;Opt('MustDeclareVars', 1)
Dim $db = @ScriptDir & "\Chocolate Notes.txt"
Dim $Sections = IniReadSectionNames($db)
Local $TabItem[$Sections[0] + 1], $TabMenu, $msg

GUICreate("INI by Tabs", 750, 650); will create a dialog box that when displayed is centered

GUISetFont(9, 300)

$TabMenu = GUICtrlCreateTab(10, 10, 735, 635)

For $i = 1 To $Sections[0]
    $SectionContents = IniReadSection($db, $Sections[$i])
    $TabItem[$i] = GUICtrlCreateTabItem($Sections[$i])
    $TabItem[$i] = ""
    For $ii=1 To $SectionContents[0][0] ; [n][0]=key [n][1]=value
        $TabItem[$i] = $tabItem[$i] & $SectionContents[$ii][0] & " = " &  $SectionContents[$ii][1] & @CRLF
    Next
    GUICtrlCreateLabel($TabItem[$i], 30, 80, 600, 20 * $ii)
Next

GUICtrlCreateTabItem(""); end tabitem definition

GUISetState()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $TabMenu Then
        ; display the clicked tab
        WinSetTitle("My GUI Tab", "", "My GUI Tab" & GUICtrlRead($TabMenu))
    EndIf
WEnd

I really just slapped it together sorry for ugly code. Hope this helps someone.

Share this post


Link to post
Share on other sites



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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0