argumentum

keep gui data in array UDF/framework idea ?

3 posts in this topic

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 :)

Share this post


Link to post
Share on other sites



1) why not ?  it depends on the wanted subsequent use
2) no
3) not really. see 2nd part of 1)
4) very subjective. It looks a lot like IBM (intense brain masturbation) , but ... see both parts of 1)
:)
 

1 person likes this

Share this post


Link to post
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. 

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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