Jump to content

keep gui data in array UDF/framework idea ?


Recommended Posts

1) Would a style of coding where everything of the GUI is in an array make sense ?
2) Can creating controls with Execute() bring trouble down the road ?

This is the basic idea:

Global $g_Gui[10][10] = [[0]]

#include <MsgBoxConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $eGui = GUICtrlArray('GUICreate',"Form1", 305, 269, 50, 50, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
Global $eInputForGofigure = GUICtrlArray("GUICtrlCreateInput","Input1", 32, 32, 121, 21,-1, -1, $GUI_DOCKLEFT+$GUI_DOCKTOP+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
Global $eEditForGofigure = GUICtrlArray('GUICtrlCreateEdit',"Edit1"&@CRLF&"=P", 32, 72, 185, 89,-1, -1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM)
Global $eBttnShowArray = GUICtrlArray("GUICtrlCreateButton","Show Gui array", 176, 24, 100, 25,-1, -1, $GUI_DOCKLEFT+$GUI_DOCKTOP+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
Global $eLabelForGofigure = GUICtrlArray("GUICtrlCreateLabel","Label1", 40, 180, 180, 17,-1, -1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKBOTTOM+$GUI_DOCKHEIGHT)
GUISetState(@SW_SHOW)


Func GUICtrlArray($sCtrl, $sText, $iLeft, $iTop , $iWidth = default , $iHeight = default , $iStyle = -1, $iExStyle = -1, $iResize = 0)
    $g_Gui[0][0] += 1
    Local $i = $g_Gui[0][0]
    $g_Gui[$i][1] = $sCtrl
    $g_Gui[$i][2] = $sText
    $g_Gui[$i][3] = $iTop
    $g_Gui[$i][4] = $iWidth
    $g_Gui[$i][5] = $iHeight
    $g_Gui[$i][6] = $iStyle
    $g_Gui[$i][7] = $iExStyle
    $g_Gui[$i][8] = $iResize
    $g_Gui[$i][9] = "anything thing else ?"
    Switch $sCtrl
        Case "GUICreate"
            $g_Gui[$i][0] = Execute($sCtrl & "('" & $sText & "'," & $iLeft & "," & $iTop & "," & $iWidth & "," & $iHeight & "," & $iStyle & "," & $iExStyle & "," & $iResize & ")")
        Case Else
            $g_Gui[$i][0] = Execute($sCtrl & "('" & $sText & "'," & $iLeft & "," & $iTop & "," & $iWidth & "," & $iHeight & "," & $iStyle& "," & $iExStyle & ")")
            If $iResize Then GUICtrlSetResizing($g_Gui[$i][0], $iResize)
    EndSwitch
    Return $i
EndFunc


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
        Case $g_Gui[$eBttnShowArray][0]
            _ArrayDisplay($g_Gui, "$g_Gui")

    EndSwitch
WEnd

3) Do you have an idea to make this "mode of coding" more functional ?
4) Is this a waste of time ( for 1 or more reasons ) ?

As always, anything you post will be used against you is welcomed :)

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

I have tried something similar (but not very elaborated) in my ADAT tool (posted in the example scripts section). 

A tab per GUI, a few lines to create the GUI and a function per GUI to process the entered data. 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...