Jump to content

GUI Encapsulation.


Recommended Posts

Hi guys. Just a little question. I am not new in AutoIt, or programming in general, so you can answer me the hardest way that you can. Do you think is a good idea encapsulate a GUI(Main and the only GUI in the script) in a func? Not a func that have a loop and still until the user ends, just a func to create the GUI in vars already declared as global(the script is on event mode, so the variables can be local too without any problem, because I don't need them later in a GUIGetMsg loop) and then return. It's a good idea or a bad idea? Or the worst idea in all the time and space?

Global Const iX = 300, $iY = 600
Global Const $sTitle = 'Patheditor', $sAddButtonText = 'Add', $sDeleteButtonText = 'Delete'

Global $hMainGui
Global $iAddButton, $iDeleteButton, $iPathList

_MainGuiStartup()
_RefreshList()
_MainLoop()

Func _MainGuiStartup()
$hMainGui = GUICreate($sTitle, $iX, $iY)
$iAddButton = GUICtrlCreateButton($sAddButtonText, 2, $iY - (($iY / 24) - 2), ($iX / 2) - 1, $iY / 24)
$iDeleteButton = GUICtrlCreateButton($sDeleteButtonText, ($iX / 2) + 1, $iY - (($iY / 24) - 2), ($iX / 2) - 1, $iY / 24)
$iPathList = GUICtrlCreateList('', 2, 2, $iX - 2, $iY - (($iY / 24) - 5))
Local $aMainGuiAccelTable[2][2] = [['^a', $iAddButton], ['^d', $iDeleteButton]+
GUISetState(@SW_SHOW, $hMainGui)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit')
GUICtrlSetOnEvent($iAddButton, '_Add')
GUICtrlSetOnEvent($iDeleteButton, '_Delete')
GUISetAccelerators($aMainGuiAccelTable, $hMainGui)
Endfunc

Codes codes codes.

Link to comment
Share on other sites

Was the time and space comment along with hair disturbingly similar to Tom Baker a deliberate Dr Who reference?

re the gui encapsulation in a function, I wouldn't bother putting it in a function as the code won't be reused.  Still, if it improves readability for you then it doesn't do any harm.

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