Sign in to follow this  
Followers 0
DarkBoost

GUICtrlCreateLabel

3 posts in this topic

I have created a very basic GUI with a button which displays a different label based on the user input however I am unsure how to clear the existing data when new data is to be displayed (see attachment). Any assistance would be greatly appreciated, thanks :)

#include <GUIConstantsEx.au3>

GUICreate("example", 200, 100)
GUICtrlCreateLabel("Type => 1 or 2 <= for message", 10, 10)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$input = GUICtrlCreateInput("", 115, 71, 30, 20)
$button = GUICtrlCreateButton("GO", 150, 70, 40, 22)

GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $button
            If GUICtrlRead($input) = "1" Then
                GUICtrlCreateLabel("1. Hello World", 10, 50)
                GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
            ElseIf GUICtrlRead($input) = "2" Then
                GUICtrlCreateLabel("2. Goodbye World", 10, 50)
                GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) 
            EndIf
            
        Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
WEnd

post-24114-1233873062_thumb.jpg

Share this post


Link to post
Share on other sites



#include <GUIConstantsEx.au3>

GUICreate("example", 200, 100)
GUICtrlCreateLabel("Type => 1 or 2 <= for message", 10, 10)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$input = GUICtrlCreateInput("", 115, 71, 30, 20)
$button = GUICtrlCreateButton("GO", 150, 70, 40, 22)
$label = GUICtrlCreateLabel("", 10, 50, 150, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) 
   GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $button
            $what = GUICtrlRead($input)
            If $what = "1" Then
                GUICtrlSetData($label, "1. Hello World")
            ElseIf $what = "2" Then
                GUICtrlSetData($label, "2. Goodbye World")
            EndIf
                    Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Ah of course, thanks for your assistance Zedna

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