Jump to content

Recommended Posts

Posted (edited)

This is my first attempt at creating a GUI and have drawn up what I am trying to achieve.

Any thoughts regarding how I should tackle the coding would be greatly appreciated.

Edited by DarkBoost
Posted

I have found endless examples/tutorials of how to create a GUI window but none which show how to program them.

Example 1. How to add a checkbox but not how to program it when it is ticked/unticked

Example 2. How to add a button but now how to program it when a user clicks on it.

Is there any examples/tutorials which will take you past creating the GUI and onto coding it?

Sucks being a noob :-(

Posted

after creating the gui with koda generate the code.

example of gui with a button

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 268, 210, 252, 172)
$Button1 = GUICtrlCreateButton("Button1", 96, 72, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

now if you want to show a message box on clicking the button then

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 268, 210, 252, 172)
$Button1 = GUICtrlCreateButton("Button1", 96, 72, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            MsgBox(64, "Test", "Button is working and will timeout in 10sec.", 10)
    EndSwitch
WEnd

see the difference line 15-18 to know how "Cases" works!

Posted

i think i could not understand what you really want to achieve/accomplish. can you explain your problem? i think you want to know how controls/buttons works....

Posted

There is something wrong with this forum...

Everything is continually freezing.

Here's my attempt, hope you learn best by example:

Opt("GUIOnEventMode",1)

Global $guiMain, $labelInstalled[5], $buttonInstall[5]

$guiMain = GUICreate("Application GUI",345,150)

GUICtrlCreateLabel("Notepad",5,5,100,20)
GUICtrlCreateLabel("App 2",5,35,100,20)
GUICtrlCreateLabel("App 3",5,65,100,20)
GUICtrlCreateLabel("App 4",5,95,100,20)
GUICtrlCreateLabel("App 5",5,125,100,20)

For $z = 0 To 4
    $labelInstalled[$z] = GUICtrlCreateLabel("Installed",120,5 + 30 * $z,100,20)
    GUICtrlSetColor(-1,0x00FF00)
    $buttonInstall[$z] = GUICtrlCreateButton("Remove",240,5 + 30 * $z,100,20)
    GUICtrlSetOnEvent(-1,"InstallApp")
Next

GUISetOnEvent(-3,"Quit")

GUISetState()

While 1
    Sleep(25)
WEnd

Func InstallApp()
    Local $index = (@GUI_CtrlId - $buttonInstall[0])/2
    
    If GUICtrlRead($labelInstalled[$index]) = "Installed" Then
        GUICtrlSetData($labelInstalled[$index],"Not Installed")
        GUICtrlSetColor($labelInstalled[$index],0xFF0000)
        
        GUICtrlSetData($buttonInstall[$index],"Install")
    Else
        GUICtrlSetData($labelInstalled[$index],"Installed")
        GUICtrlSetColor($labelInstalled[$index],0x00FF00)
        
        GUICtrlSetData($buttonInstall[$index],"Remove")
    EndIf
EndFunc

Func Quit()
    Exit
EndFunc

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
  • Recently Browsing   0 members

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