Jump to content

Good GUI Design Practice?


Recommended Posts

Hi!

I'm experimenting with writing a GUI. I decided to try a roundabout way. I was wondering if you could tell me if this is good programming practice? The only thing that you can know about a control is the ControlID. I think that is what I'm going for here.

This GUI has no practical purpose other than experimenting. I welcome any and all thoughts, opinions, and criticisms relating to this thread. Thanks and have a wonderful (day|night)!

Local $FormID = _createGUI()

Func _getGUIWidth()
    Return @DesktopWidth - 600
EndFunc ;==>_getGUIWidth

Func _getGUIHeight()
    Return @DesktopHeight - 500
EndFunc ;==>_getGUIHeight

Func _getGUILeft()
    Return 10
EndFunc ;==>_getGUILeft

Func _getGUITop()
    Return 10
EndFunc ;==>_getGUITop

Func _createGUI()
    ; create the gui form
    Local $apFormWidth = _getGUIWIdth()
    Local $apFormHeight = _getGUIHeight()
    Local $apFormLeft = _getGUILeft()
    Local $apFormTop = _getGUITop()

    Return GUICreate("Experiment", $apFormWidth, $apFormHeight, _getGUILeft(), _getGUITop())
EndFunc ;==>_createGUI

; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Local $fileListID = _createFileList()

Func _getFileListWidth()
    Return 300
EndFunc ;==>_getFileListWidth

Func _getFileListHeight()
    Return 15 * 8
EndFunc ;==>_getFileListHeight

Func _getFileListLeft()
    Return _getGUIWIdth() - _getFileListWidth() - 10
EndFunc ;==>_getFileListLeft

Func _getFileListTop()
    Return 10
EndFunc ;==>_getFileListTop

Func _createFileList()
    Local $apFileListWidth = _getFileListWidth()
    Local $apFileListHeight = _getFileListHeight()
    Local $apFileListLeft = _getFileListLeft()
    Local $apFileListTop = _getFileListTop()

    Return GUICtrlCreateList("", $apFileListLeft, $apFileListTop, $apFileListWidth, $apFileListHeight)
EndFunc ;==>_createFileList

; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Local $labelID = _createLabel()

Func _getLabelWidth()
    Return _getGUIWIdth() - 20
EndFunc ;==>_getLabelWidth

Func _getLabelHeight()
    Return 30
EndFunc ;==>_getLabelHeight

Func _getLabelLeft()
    Return 10
EndFunc ;==>_getFileListLeft

Func _getLabelTop()
    Return _getFileListHeight() + 10
EndFunc ;==>_getFileListTop

Func _createLabel()
    Local $apLabelWidth = _getLabelWidth()
    Local $apLabelHeight = _getLabelHeight()
    Local $apLabelLeft = _getLabelLeft()
    Local $apLabelTop = _getLabelTop()

    Return GUICtrlCreateLabel("", $apLabelLeft, $apLabelTop, $apLabelWidth, $apLabelHeight)
EndFunc ;==>_createLabel

Func _messageSend($data = '', $controlID = $labelID)
    Return GUICtrlSetData($controlID, $data)
EndFunc ;==>_messageSend

; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

GUISetState(@SW_SHOW)

_messageSend("HI")
Sleep(2000)
_messageSend()

Sleep(2000)

Yes, I recently began learning OOP.

Edited by jaberwocky6669
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...