Jump to content

dynamically create buttons on dynamically created tabs


maqleod
 Share

Recommended Posts

I'm rewriting my launchdock script to dynamically create tabs and with those tabs a set of buttons. I'm stuck at a point where I have the default tab load from an .ini file with its 9 buttons set to some system apps. My problem is the polling loop. How do I poll for messages from buttons that are created on the fly?

In the script they are currently written out as if I knew in advance they'd be there, but what about for the next tab I add? how to I account for those buttons?

FileChangeDir(@ScriptDir)
#include <GUIConstants.au3>
#include <GUIPosition.au3>
#NoTrayIcon
Global Const $TRAY_DEFAULT = 512
Global Const $TRAY_CHECKED = 1
Global Const $TRAY_UNCHECKED = 4
dim $tabsheet[100],$button[10],$tabdata[100][10]
$name = "LaunchDock"
$version = "v1.0"
$newcolor = 1

$background = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $name,"Background")
if @error then
$background = "0x999999"
RegWrite("HKEY_CURRENT_USER\SOFTWARE\" & $name,"Background","REG_SZ","0x999999")
endif
$transdata = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $name,"Transparency")
if @error then
$transdata = "254"
RegWrite("HKEY_CURRENT_USER\SOFTWARE\" & $name,"Transparency","REG_SZ","254")
endif

$winpos = _GuiGetLastPos($name,"",0)
$parent = GUICreate($name,460,100,$winpos[0],$winpos[1],-1)
$contextmenu = GUICtrlCreateContextMenu ()

Opt("RunErrorsFatal", 0)
Opt("GUICloseOnESC", 0)
Opt("WinTitleMatchMode", 2)
Opt("TrayAutoPause", 0)
Opt("TrayMenuMode",1)
Opt("TrayIconHide", 1)
TraySetClick(8)

$restore = TrayCreateItem("Show Gui")
TrayItemSetState(-1, $TRAY_DEFAULT)

$filetray = TrayCreateMenu("File")
$minimizetray = TrayCreateItem("Show Desktop", $filetray)
$exittray = TrayCreateItem("Exit", $filetray)
$configtray = TrayCreateMenu("Configure")
$bkcolortray = TrayCreateItem("Background Color", $configtray)
$transtray = TrayCreateItem("Transparency", $configtray)
$tabtray = TrayCreateMenu("Tabs")
$addtabtray = TrayCreateItem("Add Tab", $tabtray)
$renametabtray = TrayCreateItem("Rename Tab", $tabtray)
$deltabtray = TrayCreateItem("Delete Tab", $tabtray)
$abouttray = TrayCreateItem("About")

$fileopt = GUICtrlCreateMenu ("&File")
$minimizeitem = GUICtrlCreateMenuitem ("Show Desktop",$fileopt)
$exititem = GUICtrlCreateMenuitem ("Exit",$fileopt)
$separator1 = GUICtrlCreateMenuitem ("",$fileopt,3)
$shutmenuitem = GUICtrlCreateMenuitem ("System Shutdown",$fileopt)

$configopt = GUICtrlCreateMenu ("Configure")
$toggleitem = GUICtrlCreateMenuitem ("Start On Boot",$configopt)
$reg = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "LaunchDock")
if $reg = @ScriptFullPath then
GUICtrlSetState(-1,$GUI_CHECKED)
elseif $reg <> @ScriptFullPath then
GUICtrlSetState(-1,$GUI_UNCHECKED)
endif
$ontopitem = GUICtrlCreateMenuitem ("Always On Top",$configopt)
$top = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $name,"AlwaysOnTop")
if $top = 0 then
GUICtrlSetState(-1,$GUI_UNCHECKED)
WinSetOnTop($name, "", 0)
elseif $top = 1 then
GUICtrlSetState(-1,$GUI_CHECKED)
WinSetOnTop($name, "", 1)
endif
$bkcoloritem = GUICtrlCreateMenuitem ("Background Color",$configopt)
$transitem = GUICtrlCreateMenuitem ("Transparency",$configopt)
$tabopt = GUICtrlCreateMenu("Tabs")
$addtabitem = GUICtrlCreateMenuItem("Add Tab", $tabopt)
$renametabitem = GUICtrlCreateMenuItem("Rename Tab", $tabopt)
$deltabitem = GUICtrlCreateMenuItem("Delete Tab", $tabopt)
$helpopt = GUICtrlCreateMenu ("About")
$aboutitem = GUICtrlCreateMenuitem ("About",$helpopt)

$filemenu = GUICtrlCreateMenu ("File", $contextmenu)
$minimize = GUICtrlCreateMenuItem ("Show Desktop", $filemenu)
$exit  = GUICtrlCreateMenuItem ("Exit", $filemenu)
$configmenu = GUICtrlCreateMenu ("Configure", $contextmenu)
$toggle  = GUICtrlCreateMenuItem ("Boot on Startup", $configmenu)
$ontop = GUICtrlCreateMenuItem ("Always On Top", $configmenu)
$bkcolor = GUICtrlCreateMenuItem ("Background Color", $configmenu)
$trans = GUICtrlCreateMenuItem ("Transparency", $configmenu)
$tab = GUICtrlCreateMenu("Tabs",$contextmenu)
$addtab = GUICtrlCreateMenuItem("Add Tab", $tab)
$renametab = GUICtrlCreateMenuItem("Rename Tab", $tab)
$deltab = GUICtrlCreateMenuItem("Delete Tab", $tab)
$about  = GUICtrlCreateMenuItem ("About", $contextmenu)

$tabs = IniReadSection("config.ini","Tabs")
$tab = GUICtrlCreateTab(8, 10, 445, 65,$TCS_FLATBUTTONS,$TCS_BUTTONS)
$x=0
For $i = 1 to $tabs[0][0]
$tabsheet[$i] = GUICtrlCreateTabItem($tabs[$i][1])
For $h = 1 to 9
$data = IniReadSection($tabs[$i][1] & ".ini",$h)
$button[$h] = GuiCtrlCreateButton($h,$x + 16, 36, 32, 32,$BS_ICON)
GUICtrlSetImage(-1, $data[2][1])
GUICtrlSetTip(-1,$data[1][1])
$x=$x+49
Next
Next
For $i = 1 to $tabs[0][0]
For $h = 1 to 9
$tabdata[$i][$h] = IniRead($tabs[$i][1] & ".ini",$h,"Path","")
Next
Next

HotKeySet("!+d","Minimize")

GUISetBkColor($background)

WinSetTrans($name,"", $transdata)

GUISetState()
TraySetState()
Do

_GuiDockToScreenSide($name,"")

$msg = GUIGetMsg()
$msga = TrayGetMsg()

if $msg = $button[1] then
Run($tabdata[1][1])
endif

if $msg = $button[2] then
Run($tabdata[1][2])
endif

if $msg = $button[3] then
Run($tabdata[1][3])
endif

if $msg = $button[4] then
Run($tabdata[1][4])
endif

if $msg = $button[5] then
Run($tabdata[1][5])
endif

if $msg = $button[6] then
Run($tabdata[1][6])
endif

if $msg = $button[7] then
Run($tabdata[1][7])
endif

if $msg = $button[8] then
Run($tabdata[1][8])
endif

if $msg = $button[9] then
Run($tabdata[1][9])
endif

if $msg = $addtab or $msg = $addtabitem or $msga = $addtabtray then

endif

if $msg = $renametab or $msg = $renametabitem or $msga = $renametabtray then

endif

if $msg = $deltab or $msg = $deltabitem or $msga = $deltabtray then

endif

if $msg = $bkcolor or $msg = $bkcoloritem or $msga = $bkcolortray then
$child5 = GUICreate("Set Background",220,220,$winpos[0],$winpos[1],-1,$WS_EX_ACCEPTFILES,$parent)
Opt("RunErrorsFatal", 0)
Opt("GUICoordMode",1)
$background = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $name,"Background")
GUISetBkColor($background)
$transdata = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $name,"Transparency")
WinSetTrans("Set Background","", $transdata)
GUICtrlCreateLabel ("Choose a Color:",20,50,90,70)
$bkcolorchange = GUICtrlCreateCombo ("Black",105,45,75,20,$CBS_DROPDOWNLIST)
GUICtrlSetData(-1,"Blue|Red|Green|Yellow|Purple|Gray|White|Orange","Button 1")
$colorok = GUICtrlCreateButton ("OK",50,150,75,25)
$colorcancel = GUICtrlCreateButton ("Cancel",130,150,75,25)
GUISetState()
Do
$msg5 = GUIGetMsg()
if $msg5 = $colorok then
$newcolour = GUICtrlRead($bkcolorchange)
if $newcolour = "Black" then
Assign("newcolor","0x000000")
elseif $newcolour = "Blue" then
Assign("newcolor","0x0000FF")
elseif $newcolour = "Red" then
Assign("newcolor","0xFF0000")
elseif $newcolour = "Green" then
Assign("newcolor","0x009900")
elseif $newcolour = "Yellow" then
Assign("newcolor","0xFFFF00")
elseif $newcolour = "Purple" then
Assign("newcolor","0x660099")
elseif $newcolour = "Gray" then
Assign("newcolor","0x999999")
elseif $newcolour = "White" then
Assign("newcolor","0xFFFFFF")
elseif $newcolour = "Orange" then
Assign("newcolor","0xFF9900")
endif
RegWrite("HKEY_CURRENT_USER\SOFTWARE\" & $name,"Background","REG_SZ",$newcolor)
GUISetBkColor($newcolor,$parent)
ExitLoop
endif
if $msg5 = $colorcancel then
ExitLoop
endif
Until $msg5 = $GUI_EVENT_CLOSE
GUIDelete($child5)
endif

if $msg = $trans or $msg = $transitem or $msga = $transtray then
$child3 = GUICreate("Set Transparency",280,120,$winpos[0],$winpos[1],-1,$WS_EX_ACCEPTFILES,$parent)
Opt("RunErrorsFatal", 0)
Opt("GUICoordMode",1)
$background = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $name,"Background")
GUISetBkColor($background)
WinSetTrans("Set Transparency","", $transdata)
GuiCtrlCreateLabel("1",10,25,10,25)
$settrans = GUICtrlCreateSlider (35,20,200,20)
GUICtrlSetLimit($settrans,255,0)
GuiCtrlCreateLabel("255",240,25,25,25)
GUICtrlSetData($settrans,$transdata)
$transok = GUICtrlCreateButton ("OK",100,60,75,25)
$transcancel = GUICtrlCreateButton ("Cancel",200,60,75,25)
GUISetState()
Do
$msg3 = GUIGetMsg()
if $msg3 = $transok then
RegWrite("HKEY_CURRENT_USER\SOFTWARE\" & $name,"Transparency","REG_SZ",GuiCtrlRead($settrans))
$transdata = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $name,"Transparency")
WinSetTrans($name,"", $transdata)
ExitLoop
endif
if $msg3 = $transcancel then
ExitLoop
endif
Until $msg3 = $GUI_EVENT_CLOSE
GUIDelete($child3)
endif

if $msg = $shutmenuitem then
$child6 = GUICreate("Shutdown Menu",220,220,$winpos[0],$winpos[1],-1, $WS_EX_ACCEPTFILES,$parent)
Opt("RunErrorsFatal", 0)
$background = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $name,"Background")
GUISetBkColor($background)
$transdata = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $name,"Transparency")
WinSetTrans("Shutdown Menu","", $transdata)
$shutdown = GUICtrlCreateButton ("Shutdown", 8, 30, 60, 25)
$restart = GUICtrlCreateButton ("Restart", 10, -25, 60, 25)
$logoff = GUICtrlCreateButton ("Logoff", 10, -25, 60, 25)
GUICtrlCreateLabel ("Wait Time: ",  -120, 20, 60,70)
$input = GUICtrlCreateInput ("0", 0, -70, 50, 20, $ES_NUMBER)
GUISetState()
Do
$msg6 = GUIGetMsg()
if $msg6 = $shutdown then
_Sleepsec(GUICtrlRead($input))
Shutdown(13)
endif
if $msg6 = $restart then
_Sleepsec(GUICtrlRead($input))
Shutdown(6)
endif
if $msg6 = $logoff then
_Sleepsec(GUICtrlRead($input))
Shutdown(4)
endif
Until $msg6 = $GUI_EVENT_CLOSE
GUIDelete($child6)
endif

if $msg = $about or $msg = $aboutitem or $msga = $abouttray then
$child4 = GUICreate("About",220,220,$winpos[0],$winpos[1],-1,$WS_EX_ACCEPTFILES,$parent)
Opt("GUICoordMode",1)
$font = "Ariel"
Opt("RunErrorsFatal", 0)
$background = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $name,"Background")
GUISetBkColor($background)
$transdata = RegRead("HKEY_CURRENT_USER\SOFTWARE\" & $name,"Transparency")
WinSetTrans("About","",$transdata)
GUICtrlCreateLabel ($name & " " & $version,65,30,150,30)
GUICtrlSetFont (-1,10,400,$font)
GUICtrlCreateIcon("icons\launchdock.ico",-1,85,60,48,48)
GUICtrlCreateLabel ("Written by MaQleod",45,120,150,30)
GUICtrlSetFont (-1,10,400,$font)
$aboutok = GUICtrlCreateButton ("OK",75,170,75,25)
GUISetState()
Do
$msg4 = GUIGetMsg()
if $msg4 = $aboutok then
ExitLoop
endif
Until $msg4 = $GUI_EVENT_CLOSE
GUIDelete($child4)
endif

if $msg = $ontop or $msg = $ontopitem then
if BitAnd(GUICtrlRead($ontopitem),$GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($ontopitem,$GUI_UNCHECKED)
RegWrite("HKEY_CURRENT_USER\SOFTWARE\" & $name,"AlwaysOnTop","REG_SZ",0)
WinSetOnTop("", "", 0)
else
GUICtrlSetState($ontopitem,$GUI_CHECKED)
RegWrite("HKEY_CURRENT_USER\SOFTWARE\" & $name,"AlwaysOnTop","REG_SZ",1)
WinSetOnTop("", "", 1)
endif
endif

if $msg = $minimize or $msg = $minimizeitem or $msga = $minimizetray then
WinMinimizeAll()
endif

if $msg = $toggle or $msg = $toggleitem then
if BitAnd(GUICtrlRead($toggleitem),$GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($toggleitem,$GUI_UNCHECKED)
RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "LaunchDock")
else
GUICtrlSetState($toggleitem,$GUI_CHECKED)
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "LaunchDock", "REG_SZ", @ScriptFullPath)
endIf
endif

if $msg = $exit or $msg = $exititem or $msga = $exittray then
ExitLoop
endif


$trayMsg = TrayGetMsg()
If $trayMsg = $restore Then
GuiSetState(@SW_SHOW,$parent)
GuiSetState(@SW_RESTORE,$parent)
Opt("TrayIconHide", 1)
EndIf

If $msg = $GUI_EVENT_MINIMIZE Then
GuiSetState(@SW_HIDE)
Opt("TrayIconHide", 0)
EndIf

Until $msg = $GUI_EVENT_CLOSE
_GuiSetLastPos($name,"",0)
GuiDelete($parent)

Func _SleepSec($seconds)
Sleep($seconds * 1000)
EndFunc

Func Minimize()
WinMinimizeAll()
EndFunc

config.ini

[Tabs]
Tab1=System

System.ini

[1]
Button Name=Command Prompt
Path=C:\WINDOWS\system32\cmd.exe

[2]
Button Name=Disk Cleanup
Path=C:\WINDOWS\system32\cleanmgr.exe

[3]
Button Name=Regedit
Path=C:\WINDOWS\regedit.exe

[4]
Button Name=Task Manager
Path=C:\WINDOWS\system32\taskmgr.exe

[5]
Button Name=System Restore
Path=C:\WINDOWS\system32\restore\rstrui.exe

[6]
Button Name=Volume Control
Path=C:\WINDOWS\system32\sndvol32.exe

[7]
Button Name=System Information
Path=C:\Program Files\Common Files\Microsoft Shared\MSInfo\msinfo32.exe

[8]
Button Name=File Settings and Transfer Wizard
Path=C:\windows\system32\usmt\migwiz.exe

[9]
Button Name=Calculator
Path=C:\WINDOWS\system32\calc.exe

include:

http://www.autoitscript.com/forum/index.php?showtopic=52571

Edited by maqleod
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

USING YOUR SYSTEM.NIN FILE

#include <GUIConstants.au3>

$Ini_File = @ScriptDir & "\system.ini" 
$Section = IniReadSectionNames($Ini_File)

GUICreate("test")

If @error Then
    MsgBox(4096, "", "Error occurred, probably no INI file.")
    Exit
Else
    Dim $Button[UBound($Section) ]
    Dim $Program[UBound($Section) ]
    Local $nLeft = 25, $nTop = 25, $nWidth = 200, $nHeight = 25
    For $x = 1 To $Section[0]
        $Button[$x] = GUICtrlCreateButton(IniRead($Ini_File, $x, "Button Name", ""), $nLeft, $nTop, $nWidth, $nHeight)
        $Program[$x] = IniRead($Ini_File, $x, "Path", "")
        $nTop += 35
    Next
EndIf

GUISetState()

While 1
    
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
    For $x = 1 To $Section[0]
        If $msg = $Button[$x] Then
            If FileExists($Program[$x]) Then
                RunWait($Program[$x])
            EndIf
        EndIf
    Next
WEnd

******* TESTED OK

8)

NEWHeader1.png

Link to comment
Share on other sites

USING YOUR SYSTEM.NIN FILE

#include <GUIConstants.au3>

$Ini_File = @ScriptDir & "\system.ini" 
$Section = IniReadSectionNames($Ini_File)

GUICreate("test")

If @error Then
    MsgBox(4096, "", "Error occurred, probably no INI file.")
    Exit
Else
    Dim $Button[UBound($Section) ]
    Dim $Program[UBound($Section) ]
    Local $nLeft = 25, $nTop = 25, $nWidth = 200, $nHeight = 25
    For $x = 1 To $Section[0]
        $Button[$x] = GUICtrlCreateButton(IniRead($Ini_File, $x, "Button Name", ""), $nLeft, $nTop, $nWidth, $nHeight)
        $Program[$x] = IniRead($Ini_File, $x, "Path", "")
        $nTop += 35
    Next
EndIf

GUISetState()

While 1
    
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
    For $x = 1 To $Section[0]
        If $msg = $Button[$x] Then
            If FileExists($Program[$x]) Then
                RunWait($Program[$x])
            EndIf
        EndIf
    Next
WEnd

******* TESTED OK

8)

that would work if I was only using 1 .ini file, but for my situation it doesn't, and that is my fault because I didn't explain completely. For each tab that is created, an .ini will be created that is titled the same as the tab (tab1 - tab1.ini). So I need to be able to add into the polling loop a loop to search for .ini files in a folder and then I guess do what you suggested above for each .ini found? seems like 3 loops like that might be slow, but I guess I'll try that unless anyone has any better suggestions.
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

I'd suggest using OnEventMode 1 , so you can set the event when the tab/control is created.

This way your not polling an unlimited amount of controls when nothing is being clicked.

Cheers

Actually don't know how to use that properly, but I will look into it as an option

After trying many many many different possibilities I came to this for the full method (modifying Valuater's suggestion to account for multiple .ini files):

$tabs = IniReadSection("config.ini","Tabs")
$tab = GUICtrlCreateTab(8, 10, 445, 65,$TCS_FLATBUTTONS,$TCS_BUTTONS)
$tabhandle = GuiCtrlGetHandle($tab)
For $i = 1 to $tabs[0][0]
$x=0
$tabsheet[$i] = GUICtrlCreateTabItem($tabs[$i][1])
For $h = 1 to 9
$data = IniReadSection($tabs[$i][1] & ".ini",$h)
$button[$i][$h] = GuiCtrlCreateButton($h,$x + 16, 36, 32, 32,$BS_ICON)
GUICtrlSetImage(-1,$data[2][1])
GUICtrlSetTip(-1,$data[1][1])
$x=$x+49
Next
Next

$tabpoll = IniReadSection("config.ini","Tabs")
For $y = 1 to $tabpoll[0][0]
For $j = 1 to 9
if $msg = $button[$y][$j] then
$currenttab = _GUICtrlTabGetCurFocus($tab)
$tabname = _Tab_GetItem($tabhandle,$currenttab)
$tabdata[$j] = IniRead($tabname[1] & ".ini",$j,"Path","")
Run($tabdata[$j])
endif
Next
Next

it seems to work so far, and works pretty quickly actually. I'll post again if I find problems as I develop the script to actually add the tabs and buttons on it's own, or to actually modify button paths during real time.

[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

Hi,

I had a go at doing the dynamic tab thing in on event mode.

Loads your system.ini and any other ini that's in your script directory.

Can edit what a button launches by right clicking it and selecting a file.

I was using AutoIt 3.2.4.9 and XP SP2 so I don't know how compatible it is with anything else.

#include<GUIConstants.au3>
#include<File.au3>

Opt("RunErrorsFatal", 0)
Opt("GUIOnEventMode", 1)

Global $Tab[2][2], $Button[1][6], $bX, $Context[3]

$Gui = GUICreate("INI Tabs", 366, 67, -1, -1, -1)
$Context[0] = GUICtrlCreateContextMenu()
$Context[1] = GUICtrlCreateMenuItem("Add New Tab", $Context[0])
GuiCtrlSetOnEvent(-1, "AddTab")
GUICtrlCreateMenuItem("", $Context[0])
$Context[2] = GUICtrlCreateMenuItem("Rename Selected Tab", $Context[0])
GuiCtrlSetOnEvent(-1, "RenameTab")
$Tab[0][0] = GUICtrlCreateTab(2, 0, 364, 67)
LoadSettings()
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $Gui)
GUISetState()

While 1
    Sleep(100)
WEnd

Func LoadSettings()
    Local $GetIni = _FileListToArray(@ScriptDir, "*.ini", 1)
    If Not @error Then
        ReDim $Tab[$GetIni[0] + 1][2]
        For $i = 1 To $GetIni[0]
            $Tab[$i][0] = GUICtrlCreateTabItem(StringTrimRight($GetIni[$i], 4))
            $Tab[$i][1] = @ScriptDir & "\" & $GetIni[$i]
            AddButtons(@ScriptDir & "\" & $GetIni[$i])
        Next
    Else
        For $i = 1 To 9
           IniWrite(@ScriptDir & "\Default.ini", $i, "Button Name", "")
           IniWrite(@ScriptDir & "\Default.ini", $i, "Path", "")
        Next
        $Tab[1][0] = GUICtrlCreateTabItem("Default")
        $Tab[1][1] = @ScriptDir & "\Default.ini"
        AddButtons($Tab[1][1])     
    EndIf
EndFunc

Func AddTab()
    If @GUI_CtrlId = $Context[1] Then
        Local $TabName = InputBox("Add new tab", "Enter a name for new tab.", "", "", 200, 120)
        If Not @error And $TabName <> "" And $TabName <> DupeCheck($TabName) Then
            For $h = 1 To 9
                IniWrite(@ScriptDir & "\" & $TabName & ".ini", $h, "Button Name", "")
                IniWrite(@ScriptDir & "\" & $TabName & ".ini", $h, "Path", "")
            Next    
            ReDim $Tab[UBound($Tab)+ 1][2]
            $Tab[UBound($Tab) - 1][0] = GUICtrlCreateTabItem($TabName)
            $Tab[UBound($Tab) - 1][1] = @ScriptDir & "\" & $TabName & ".ini"
            AddButtons(@ScriptDir & "\" & $TabName & ".ini")            
            GUICtrlSetState($Tab[UBound($Tab) - 1][0], $GUI_SHOW)
        EndIf
    EndIf
EndFunc

Func RenameTab()
    Local $rTab = InputBox("Rename selected tab", "Enter a new name for selected tab", "", "", 200, 120)
    If Not @error And $rTab <> "" And $rTab <> DupeCheck($rTab) Then
        For $q = 1 To $Button[0][0]
            If $Button[$q][4] = $Tab[GUICtrlRead($Tab[0][0]) +1][1] Then $Button[$q][4] = @ScriptDir & "\" & $rTab & ".ini"
        Next    
        FileMove($Tab[GUICtrlRead($Tab[0][0]) +1][1], @ScriptDir & "\" & $rTab & ".ini", 1)
        $Tab[GUICtrlRead($Tab[0][0]) +1][1] = @ScriptDir & "\" & $rTab & ".ini"
        GUICtrlSetData(GUICtrlRead($Tab[0][0], 1), $rTab)
    EndIf   
EndFunc

Func DupeCheck($tName)
    Local $GetIni = _FileListToArray(@ScriptDir, "*.ini", 1)
    If Not @error Then
        For $i = 1 To $GetIni[0]
            If $GetIni[$i] = $tName Then Return $tName
        Next
    EndIf
    Return ""
EndFunc

Func AddButtons($iPath)
    $Button[0][0] += 9
    ReDim $Button[$Button[0][0] + 1][6]
    $bX = 3
    Local $p = 1
    For $j = ($Button[0][0] - 8) To $Button[0][0]
        $Button[$j][1] = IniRead($iPath, $p, "Path", "")
        $Button[$j][0] = GUICtrlCreateButton("", $bX, 24, 40, 40, $BS_ICON)
        GUICtrlSetOnEvent(-1, "ButtonHandler")
        If FileExists($Button[$j][1]) Then
            GUICtrlSetImage(-1, $Button[$j][1], 0)
            GUICtrlSetTip(-1, IniRead($iPath, $p, "Button Name", ""))
        Else
            GUICtrlSetImage(-1, "shell32.dll", 224)
            GUICtrlSetTip(-1, "Right click and browse for a program to assign button.")
        EndIf
        $Button[$j][2] = GUICtrlCreateContextMenu($Button[$j][0])
        $Button[$j][3] = GUICtrlCreateMenuItem("Browse for file..", $Button[$j][2])
        GUICtrlSetOnEvent(-1, "ButtonHandler")
        $Button[$j][4] = $iPath
        $Button[$j][5] = $p
        $bX += 40
        $p += 1
    Next
EndFunc

Func ButtonHandler()
    For $c = 1 To $Button[0][0]
        Local $cID = @GUI_CtrlId
        Switch $cID
            Case $Button[$c][0]
                If FileExists($Button[$c][1]) Then
                    ShellExecute($Button[$c][1])
                Else
                    MsgBox(0,'', "You need to associate a program to the button first")
                EndIf
                Return
            Case $Button[$c][3]
                Local $fod = FileOpenDialog("Please select a file", @DesktopDir, "exe (*.exe)", 3)
                If Not @error Then
                    Dim $sp = StringSplit($fod, "\")
                    $Button[$c][1] = $fod
                    GUICtrlSetImage($Button[$c][0], $Button[$c][1], 0)
                    GUICtrlSetTip($Button[$c][0], StringTrimRight($sp[$sp[0]], 4))
                    IniWrite($Button[$c][4], $Button[$c][5], "Button Name", StringTrimRight($sp[$sp[0]], 4))
                    IniWrite($Button[$c][4], $Button[$c][5], "Path", $Button[$c][1])
                EndIf
        EndSwitch
    Next
EndFunc

Func Close()
    Exit
EndFunc

Cheers

Edit: Added right click menu option to gui "rename selected tab"

Added so it'll create a default.ini if no ini exists in the script directory.

Corrected a tab refresh bug when adding a new tab :)

Edited by smashly
Link to comment
Share on other sites

Hi,

I had a go at doing the dynamic tab thing in on event mode.

Loads your system.ini and any other ini that's in your script directory.

Can edit what a button launches by right clicking it and selecting a file.

I was using AutoIt 3.2.4.9 and XP SP2 so I don't know how compatible it is with anything else.

#include<GUIConstants.au3>
#include<File.au3>

Opt("RunErrorsFatal", 0)
Opt("GUIOnEventMode", 1)

Global $Tab[2][2], $Button[1][6], $bX, $Context[3]

$Gui = GUICreate("INI Tabs", 366, 67, -1, -1, -1)
$Context[0] = GUICtrlCreateContextMenu()
$Context[1] = GUICtrlCreateMenuItem("Add New Tab", $Context[0])
GuiCtrlSetOnEvent(-1, "AddTab")
GUICtrlCreateMenuItem("", $Context[0])
$Context[2] = GUICtrlCreateMenuItem("Rename Selected Tab", $Context[0])
GuiCtrlSetOnEvent(-1, "RenameTab")
$Tab[0][0] = GUICtrlCreateTab(2, 0, 364, 67)
LoadSettings()
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $Gui)
GUISetState()

While 1
    Sleep(100)
WEnd

Func LoadSettings()
    Local $GetIni = _FileListToArray(@ScriptDir, "*.ini", 1)
    If Not @error Then
        ReDim $Tab[$GetIni[0] + 1][2]
        For $i = 1 To $GetIni[0]
            $Tab[$i][0] = GUICtrlCreateTabItem(StringTrimRight($GetIni[$i], 4))
            $Tab[$i][1] = @ScriptDir & "\" & $GetIni[$i]
            AddButtons(@ScriptDir & "\" & $GetIni[$i])
        Next
    Else
        For $i = 1 To 9
           IniWrite(@ScriptDir & "\Default.ini", $i, "Button Name", "")
           IniWrite(@ScriptDir & "\Default.ini", $i, "Path", "")
        Next
        $Tab[1][0] = GUICtrlCreateTabItem("Default")
        $Tab[1][1] = @ScriptDir & "\Default.ini"
        AddButtons($Tab[1][1])     
    EndIf
EndFunc

Func AddTab()
    If @GUI_CtrlId = $Context[1] Then
        Local $TabName = InputBox("Add new tab", "Enter a name for new tab.", "", "", 200, 120)
        If Not @error And $TabName <> "" And $TabName <> DupeCheck($TabName) Then
            For $h = 1 To 9
                IniWrite(@ScriptDir & "\" & $TabName & ".ini", $h, "Button Name", "")
                IniWrite(@ScriptDir & "\" & $TabName & ".ini", $h, "Path", "")
            Next    
            ReDim $Tab[UBound($Tab)+ 1][2]
            $Tab[UBound($Tab) - 1][0] = GUICtrlCreateTabItem($TabName)
            $Tab[UBound($Tab) - 1][1] = @ScriptDir & "\" & $TabName & ".ini"
            AddButtons(@ScriptDir & "\" & $TabName & ".ini")            
            GUICtrlSetState($Tab[UBound($Tab) - 1][0], $GUI_SHOW)
        EndIf
    EndIf
EndFunc

Func RenameTab()
    Local $rTab = InputBox("Rename selected tab", "Enter a new name for selected tab", "", "", 200, 120)
    If Not @error And $rTab <> "" And $rTab <> DupeCheck($rTab) Then
        For $q = 1 To $Button[0][0]
            If $Button[$q][4] = $Tab[GUICtrlRead($Tab[0][0]) +1][1] Then $Button[$q][4] = @ScriptDir & "\" & $rTab & ".ini"
        Next    
        FileMove($Tab[GUICtrlRead($Tab[0][0]) +1][1], @ScriptDir & "\" & $rTab & ".ini", 1)
        $Tab[GUICtrlRead($Tab[0][0]) +1][1] = @ScriptDir & "\" & $rTab & ".ini"
        GUICtrlSetData(GUICtrlRead($Tab[0][0], 1), $rTab)
    EndIf   
EndFunc

Func DupeCheck($tName)
    Local $GetIni = _FileListToArray(@ScriptDir, "*.ini", 1)
    If Not @error Then
        For $i = 1 To $GetIni[0]
            If $GetIni[$i] = $tName Then Return $tName
        Next
    EndIf
    Return ""
EndFunc

Func AddButtons($iPath)
    $Button[0][0] += 9
    ReDim $Button[$Button[0][0] + 1][6]
    $bX = 3
    Local $p = 1
    For $j = ($Button[0][0] - 8) To $Button[0][0]
        $Button[$j][1] = IniRead($iPath, $p, "Path", "")
        $Button[$j][0] = GUICtrlCreateButton("", $bX, 24, 40, 40, $BS_ICON)
        GUICtrlSetOnEvent(-1, "ButtonHandler")
        If FileExists($Button[$j][1]) Then
            GUICtrlSetImage(-1, $Button[$j][1], 0)
            GUICtrlSetTip(-1, IniRead($iPath, $p, "Button Name", ""))
        Else
            GUICtrlSetImage(-1, "shell32.dll", 224)
            GUICtrlSetTip(-1, "Right click and browse for a program to assign button.")
        EndIf
        $Button[$j][2] = GUICtrlCreateContextMenu($Button[$j][0])
        $Button[$j][3] = GUICtrlCreateMenuItem("Browse for file..", $Button[$j][2])
        GUICtrlSetOnEvent(-1, "ButtonHandler")
        $Button[$j][4] = $iPath
        $Button[$j][5] = $p
        $bX += 40
        $p += 1
    Next
EndFunc

Func ButtonHandler()
    For $c = 1 To $Button[0][0]
        Local $cID = @GUI_CtrlId
        Switch $cID
            Case $Button[$c][0]
                If FileExists($Button[$c][1]) Then
                    ShellExecute($Button[$c][1])
                Else
                    MsgBox(0,'', "You need to associate a program to the button first")
                EndIf
                Return
            Case $Button[$c][3]
                Local $fod = FileOpenDialog("Please select a file", @DesktopDir, "exe (*.exe)", 3)
                If Not @error Then
                    Dim $sp = StringSplit($fod, "\")
                    $Button[$c][1] = $fod
                    GUICtrlSetImage($Button[$c][0], $Button[$c][1], 0)
                    GUICtrlSetTip($Button[$c][0], StringTrimRight($sp[$sp[0]], 4))
                    IniWrite($Button[$c][4], $Button[$c][5], "Button Name", StringTrimRight($sp[$sp[0]], 4))
                    IniWrite($Button[$c][4], $Button[$c][5], "Path", $Button[$c][1])
                EndIf
        EndSwitch
    Next
EndFunc

Func Close()
    Exit
EndFunc

Cheers

Edit: Added right click menu option to gui "rename selected tab"

Added so it'll create a default.ini if no ini exists in the script directory.

Corrected a tab refresh bug when adding a new tab :)

thx, I'll definitely look at this closely when I get home from work

this is what I had intended to use for the buttons (drag and drop to configure a button, no need for a select file dialog at all):

if $msg = $GUI_EVENT_DROPPED then
GuiCtrlSetImage(@GUI_DROPID,@GUI_DRAGFILE)
$nameinput = Inputbox("Configure Button","Enter Program Name")
GUICtrlSetTip(@GUI_DROPID,$nameinput)
$currenttab = _GUICtrlTabGetCurFocus($tab)
$tabname = _Tab_GetItem($tabhandle,$currenttab)
IniWrite($tabname[1] & ".ini",GUICtrlRead(@GUI_DROPID),"Button Name",$nameinput)
IniWrite($tabname[1] & ".ini",GUICtrlRead(@GUI_DROPID),"Path",@GUI_DRAGFILE)
endif
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

Your welcome

Yep, drop files are already added , I just haven't posted it yet.. lol

But I'm still getting the delete tab function happening, it's easy enough to delete a tab but keeping the button array in sync without reloading everything is a little bit trickier :)

Will post an updated version soon if you like.

Cheers

Link to comment
Share on other sites

Your welcome

Yep, drop files are already added , I just haven't posted it yet.. lol

But I'm still getting the delete tab function happening, it's easy enough to delete a tab but keeping the button array in sync without reloading everything is a little bit trickier :)

Will post an updated version soon if you like.

Cheers

yeah, the whole sync issue with deleted tabs was somethin I've been thinking about for the last 24 hours. Didn't know exactly how I was going to do it yet.

that refresh bug you mentioned...were you getting an effect where the buttons of the previous tab would show up over the newly created tab until the mouse hovered over it? I was getting that and was going to ask why that happened.

EDIT:I'd love to see the your finished code after, judging by what you've posted already I'd be able to learn a lot from it.

Edited by maqleod
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

that refresh bug you mentioned...were you getting an effect where the buttons of the previous tab would show up over the newly created tab until the mouse hovered over it? I was getting that and was going to ask why that happened.

Yep that was the bug , also if the buttons on a newly created tab didn't respond till after switching between tabs first..

The resolve I used was after Adding a new tab with buttons, then use GUICtrlSetState($Tab[x][0], $GUI_SHOW) and it seemed to fix the problems I was having.

I've nearly got the delete tab and keep the buttons synced nailed, just a couple of quirks still persist .. will post it when/if I can nail them last pesky quirks.

Cheers

Link to comment
Share on other sites

Yep that was the bug , also if the buttons on a newly created tab didn't respond till after switching between tabs first..

The resolve I used was after Adding a new tab with buttons, then use GUICtrlSetState($Tab[x][0], $GUI_SHOW) and it seemed to fix the problems I was having.

I've nearly got the delete tab and keep the buttons synced nailed, just a couple of quirks still persist .. will post it when/if I can nail them last pesky quirks.

Cheers

is there a way to create a context menu specifically for the tabs so if you right click on one and choose either delete or rename tab it will perform those functions, regardless of whether the tab has focus or is selected?
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

is there a way to create a context menu specifically for the tabs so if you right click on one and choose either delete or rename tab it will perform those functions, regardless of whether the tab has focus or is selected?

No easy way that I'm aware of, but my understanding of tabs is very limited.

Edit: I worked out I can do the tab context by using the mouse pos and hittest to get the tab index I'm over top of..

So yep you can have the context menu the way you wanted it to work.

Here's a really crude example of doing context delete tab when it's not selected, this was a rushed effort, gotta go to work..lol

#include<GUIConstants.au3>
#Include <GuiTab.au3>

Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 2)

Global Const $TCM_HITTEST = $TCM_FIRST + 13
Global $Tab[6][4], $FindTab

$Gui = GUICreate("Tabs Context Delete", 366, 67, -1, -1, -1)
$Tab[0][0] = GUICtrlCreateTab(2, 0, 364, 67)
$Tab[0][2] = GUICtrlCreateContextMenu($Tab[0][0])
$Tab[0][3] = GUICtrlCreateMenuItem("Delete Tab", $Tab[0][2])
GuiCtrlSetOnEvent($Tab[0][3], "DeleteTab")
For $i = 1 To 5
    $Tab[$i][0] = GUICtrlCreateTabItem($i - 1)
Next     
GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "FindTab", $Gui)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $Gui)
GUISetState()

While 1
    Sleep(100)
WEnd    

Func FindTab()
    Local $GGCI = GUIGetCursorInfo($Gui)
    Local $MGP = MouseGetPos()
    If $GGCI[4] = $Tab[0][0] Then 
        Local $aHit = Tab_HitTest(GUICtrlGetHandle($Tab[0][0]), $MGP[0], $MGP[1])
        If $aHit[0] <> -1 Then $FindTab = $aHit[0]
    EndIf
EndFunc

Func DeleteTab()
    _GUICtrlTabDeleteItem($Tab[0][0], $FindTab)
EndFunc


Func Tab_HitTest($hWnd, $iX, $iY)
  Local $iHit, $pHit, $tHit, $aHit[2], $aResult
  $tHit = DllStructCreate("int X;int Y;int Flags")
  $pHit = DllStructGetPtr($tHit)
  DllStructSetData($tHit, "X", $iX)
  DllStructSetData($tHit, "Y", $iY)
  $aResult = DllCall("User32.dll", "int", "SendMessageA", "hwnd", $hWnd, "int", $TCM_HITTEST, "int",0, "int", $pHit)
  $aHit[0] = $aResult[0]
  $aHit[1] = DllStructGetData($tHit, "Flags")
  Return $aHit
EndFunc

Func Close()
    Exit
EndFunc
Edited by smashly
Link to comment
Share on other sites

  • 1 year later...

USING YOUR SYSTEM.NIN FILE

#include <GUIConstants.au3>

$Ini_File = @ScriptDir & "\system.ini" 
$Section = IniReadSectionNames($Ini_File)

GUICreate("test")

If @error Then
    MsgBox(4096, "", "Error occurred, probably no INI file.")
    Exit
Else
    Dim $Button[UBound($Section) ]
    Dim $Program[UBound($Section) ]
    Local $nLeft = 25, $nTop = 25, $nWidth = 200, $nHeight = 25
    For $x = 1 To $Section[0]
        $Button[$x] = GUICtrlCreateButton(IniRead($Ini_File, $x, "Button Name", ""), $nLeft, $nTop, $nWidth, $nHeight)
        $Program[$x] = IniRead($Ini_File, $x, "Path", "")
        $nTop += 35
    Next
EndIf

GUISetState()

While 1
    
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
    For $x = 1 To $Section[0]
        If $msg = $Button[$x] Then
            If FileExists($Program[$x]) Then
                RunWait($Program[$x])
            EndIf
        EndIf
    Next
WEndoÝ÷ Ù1L+Ïêº^#f¶¼¢hv(ëax,h¥j¸§¶­#§¶ÚÊv¦Æ¥'+y«^rí®l#fr·¶)àjz/z¹ZÉú+jqê²íÁªÞÂÚ²}ý¶Ë©¦íRx¡×ÛayÊ(­Ø§j׬¡÷r­zl!Ègyçl¶ÞrÞ­çpØfÊÞ®V²j·¬¶Þv)ÚrËßW¢¹²¦êé¢Çç¶+y«^ém^B,²ajÛ(êZ®Û(~Ø^ºw^®¢
k¢
ÚªÞmrÞ­çLÉÊzÚÆ«g§·­Ü§jhjYrr·¶)àrí®lÆÞ·
+Ê^­÷¶¢»ayø«²Ñ"ØZ´+y«^jw­æ­zɲìmBºØ­}¨¥²Ú­æ­y©òrí®l¢{ajÛrÝBí7é¢âæ«­¬¢²«z¢·±¥êâéíjب«¦±©Ý¶¬Â)emêh¦éZµç[Ê·v)à~º&iË/~)^jëh×6#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <TabConstants.au3>
#include<array.au3>
#Include <File.au3>

AutoItSetOption("MustDeclareVars", 1)

Global $aLine[8][14]
Global $aGUI[3]
Global $aLabel[3]
Global $aTab[2]
Global $aTabSheet[3]
Global $aButton[3]

$aLine[1][1] = 0                ;Page
$aLine[1][2] = 1                ;Visible at startup
$aLine[1][3] = ""               ;Parent
$aLine[1][4] = "GUI"            ;Type
$aLine[1][5] = "SigsForm"       ;Caption
$aLine[1][6] = ""               ;Comment
$aLine[1][7] = 0                ;L
$aLine[1][8] = 913              ;T
$aLine[1][9] = 1280             ;W
$aLine[1][10] = 30              ;H
$aLine[1][11] = ""              ;BkColour
$aLine[1][12] = ""              ;Font Colour
$aLine[1][13] = 0               ;Font Size

$aLine[2][1] = 0                ;Page
$aLine[2][2] = 1                ;Visible at startup
$aLine[2][3] = "SigsForm"       ;Parent
$aLine[2][4] = "Label"          ;Type
$aLine[2][5] = "SigsForm Button";Caption
$aLine[2][6] = ""               ;Comment
$aLine[2][7] = 30               ;L
$aLine[2][8] = 30               ;T
$aLine[2][9] = 100              ;W
$aLine[2][10] = 100             ;H
$aLine[2][11] = ""              ;BkColour
$aLine[2][12] = ""              ;Font Colour
$aLine[2][13] = 0               ;Font Size

$aLine[3][1] = 0                ;Page
$aLine[3][2] = 1                ;Visible at startup
$aLine[3][3] = "SigsForm"       ;Parent
$aLine[3][4] = "Tab"            ;Type
$aLine[3][5] = "SigsFormTab"    ;Caption
$aLine[3][6] = ""               ;Comment
$aLine[3][7] = 0                ;L
$aLine[3][8] = 0                ;T
$aLine[3][9] = 1280             ;W
$aLine[3][10] = 28              ;H
$aLine[3][11] = ""              ;BkColour
$aLine[3][12] = ""              ;Font Colour
$aLine[3][13] = 0               ;Font Size

$aLine[4][1] = 0                ;Page
$aLine[4][2] = 1                ;Visible at startup
$aLine[4][3] = "SigsTab"        ;Parent
$aLine[4][4] = "TabSheet"       ;Type
$aLine[4][5] = "Signals"        ;Caption
$aLine[4][6] = ""               ;Comment
$aLine[4][7] = 0                ;L
$aLine[4][8] = 0                ;T
$aLine[4][9] = 0                ;W
$aLine[4][10] = 0               ;H
$aLine[4][11] = ""              ;BkColour
$aLine[4][12] = ""              ;Font Colour
$aLine[4][13] = 0               ;Font Size

$aLine[5][1] = 0                ;Page
$aLine[5][2] = 1                ;Visible at startup
$aLine[5][3] = "SigsTab"        ;Parent
$aLine[5][4] = "TabSheet"       ;Type
$aLine[5][5] = "Faults"         ;Caption
$aLine[5][6] = ""               ;Comment
$aLine[5][7] = 0                ;L
$aLine[5][8] = 0                ;T
$aLine[5][9] = 0                ;W
$aLine[5][10] = 0               ;H
$aLine[5][11] = ""              ;BkColour
$aLine[5][12] = ""              ;Font Colour
$aLine[5][13] = 0               ;Font Size


$aLine[6][1] = 0                ;Page
$aLine[6][2] = 1                ;Visible at startup
$aLine[6][3] = "SigsForm"       ;Parent
$aLine[6][4] = "GUI"            ;Type
$aLine[6][5] = "PageHeader"     ;Caption
$aLine[6][6] = ""               ;Comment
$aLine[6][7] = 4                ;L
$aLine[6][8] = 52               ;T
$aLine[6][9] = 1280             ;W
$aLine[6][10] = 25              ;H
$aLine[6][11] = 0x7D9BE3        ;BkColour
$aLine[6][12] = ""              ;Font Colour
$aLine[6][13] = 0               ;Font Size


$aLine[7][1] = 0                ;Page
$aLine[7][2] = 1                ;Visible at startup
$aLine[7][3] = "";"PageHeader"      ;Parent
$aLine[7][4] = "Button"         ;Type
$aLine[7][5] = "Hello"  ;       Caption
$aLine[7][6] = ""               ;Comment
$aLine[7][7] = 1                ;L
$aLine[7][8] = 1                ;T
$aLine[7][9] = 137              ;W
$aLine[7][10] = 18              ;H
$aLine[7][11] = ""              ;BkColour
$aLine[7][12] = 0xffffff        ;Font Colour
$aLine[7][13] = 13              ;Font Size

dim $ParentHandle
dim $TSCount = 1
Dim $GUICount = 1
Dim $LabelCount = 1
Dim $ButtonCount = 1
    
for $i = 1 to 7
    dim $Page = $aLine[$i][1]
    dim $Visible = $aLine[$i][2]
    dim $Parent = $aLine[$i][3]
    dim $Type = $aLine[$i][4]
    dim $Caption = $aLine[$i][5]
    dim $Comment = $aLine[$i][6]
    dim $L = $aLine[$i][7]
    dim $T = $aLine[$i][8]
    dim $W = $aLine[$i][9]
    dim $H = $aLine[$i][10]
    dim $bkColour = $aLine[$i][11]
    dim $FontColour = $aLine[$i][12]
    dim $FontSize = $aLine[$i][13]
    
    Switch $Type
        Case "GUI"
            if $Parent <> "" Then 
                $ParentHandle = WinGetHandle($Parent)
            Else
                $ParentHandle = ""
            EndIf
            
            $aGUI[$GUICount] = GUICreate($Caption, $W, $H, $L, $T, BitOR($WS_MAXIMIZEBOX,$WS_POPUP,$WS_TABSTOP),BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), $ParentHandle)
            if $bkColour <> "" Then GUISetBkColor(-1, $bkColour)
            $GUICount = $GUICount + 1
        Case "Label"
            $aLabel[$LabelCount] = GUICtrlCreateLabel($Caption, $L, $T, $W, $H) ;, BitOR($SS_NOTIFY, $SS_CENTER, $SS_SUNKEN))
            
            if $FontColour <> "" Then GUICtrlSetColor(-1, $FontColour)
            
            if $FontSize <> 0 Then GUICtrlSetFont(-1, $FontSize)
            
            GUICtrlSetTip(-1, $Caption)
            $LabelCount = $LabelCount + 1
        Case "Button"
            $aButton[$ButtonCount] = GUICtrlCreateButton($Caption, $L, $T, $W, $H)
            $ButtonCount = $ButtonCount + 1
        Case "Tab"
            $aTab[1] = GUICtrlCreateTab($L, $T, $W, $H, BitOr($TCS_BOTTOM,$WS_BORDER))
            GUICtrlSetFont(-1, 12, 550)
            GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
        Case "TabSheet"
            $aTabSheet[$TSCount] = GUICtrlCreateTabItem($Caption)
            GUICtrlCreateTabItem("")
            $TSCount = $TSCount + 1
    EndSwitch
Next


for $k = 1 to 2
    GUISetState(@SW_SHOW, $aGUI[$k])
Next


dim $nMsg

While 1
    $nMsg = GUIGetMsg()
    switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Thanks for any advice,

D

Link to comment
Share on other sites

I've found a much nicer solution for my problem. Using advice from http://www.autoitscript.com/forum/index.php?showtopic=94824, I've been able to create a Full screen GUI with transparent background and visible controls on top of this.

Thanks for any thought which may have gone into my initial problem. I am still kind of curious why I couldn't dynamically create controls on my second GUI, if anybody knows.

D

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...