Sign in to follow this  
Followers 0
WoodGrain

Basic GUI with 2 buttons

6 posts in this topic

Hi guys,

Could someone please give me a head start with creating a GUI?

For my current project I want to prompt the user with a Message type box with a title, description/question & 2 buttons with the button text "Big" and "Small" and the resulting code execution based on which button they press.

That'd be a big help - thanks guys.

Share this post


Link to post
Share on other sites



Have a look in the HELP file.

Its all there.


----[ SandyD ]---

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

GUICreate ( "Insert title Here...", 266,91)

GUICtrlCreateLabel ( "Insert question here...", 20, 10, 200, 20)

$Big = GUICtrlCreateButton ( "Big", 20, 50, 100)
$Small = GUICtrlCreateButton ( "Small", 146, 50, 100)

GUISetState()

While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         ExitLoop
      Case $msg = $Big
        ;Insert Code Here
      Case $msg = $Small
        ;Insert Code Here
   EndSelect  
Wend

That will get you started. Because you wanted custom text on the button we couldnt just use a simple Msgbox() Function as the buttons can only contain set text such as "Yes", "No", "Retry" etc. Instead I had to create a custom GUI window that looks like a message box.


[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

Thanks for that.

It's just the kick start I needed to start getting my head around it (as i've only created GUIs visually before).

#include <GUIConstants.au3>

GUICreate ( "Insert title Here...", 266,91)

GUICtrlCreateLabel ( "Insert question here...", 20, 10, 200, 20)

$Big = GUICtrlCreateButton ( "Big", 20, 50, 100)
$Small = GUICtrlCreateButton ( "Small", 146, 50, 100)

GUISetState()

While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         ExitLoop
      Case $msg = $Big
        ;Insert Code Here
      Case $msg = $Small
        ;Insert Code Here
   EndSelect  
Wend

That will get you started. Because you wanted custom text on the button we couldnt just use a simple Msgbox() Function as the buttons can only contain set text such as "Yes", "No", "Retry" etc. Instead I had to create a custom GUI window that looks like a message box.

<{POST_SNAPBACK}>

Share this post


Link to post
Share on other sites

What a great editor - thanks for pointing me to it.

I'd been using Crimson Editor until now..

you might want to look at the SciTE editor

SciTE

<{POST_SNAPBACK}>

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
Sign in to follow this  
Followers 0