Difference between revisions of "Label"

From AutoIt Wiki
Jump to navigation Jump to search
m (Page Created)
 
m (Example: Syntax Highlighting & code cleanup)
Line 7: Line 7:
  
 
== Example ==
 
== Example ==
This example shows creating of an GUI Label.
+
This example demonstrates the creation of a GUI label.
 +
<syntaxhighlight lang="autoit">
 +
#include <GUIConstantsEx.au3>
  
    #include <GUIConstantsEx.au3>
+
Opt('MustDeclareVars', 1)
    Opt('MustDeclareVars', 1)
+
 
    Example()
+
Example()
    Func Example()
+
 
        Local $widthCell, $msg, $iOldOpt
+
Func Example()
        GUICreate("My GUI") ; will create a dialog box that when displayed is centered
+
    GUICreate("My GUI") ; will create a dialog box that when displayed is centered
        GUISetHelp("notepad") ; will run notepad if F1 is typed
+
 
        $iOldOpt = Opt("GUICoordMode", 2)
+
    GUISetHelp("notepad") ; will run notepad if F1 is typed
        $widthCell = 70
+
 
        GUICtrlCreateLabel("Line 1 Cell 1", 10, 30, $widthCell) ; first cell 70 width
+
    Local Const $iOldOpt = Opt("GUICoordMode", 2)
        GUICtrlCreateLabel("Line 2 Cell 1", -1, 0) ; next line
+
 
        GUICtrlCreateLabel("Line 3 Cell 2", 0, 0) ; next line and next cell
+
    Local Const $widthCell = 70
        GUICtrlCreateLabel("Line 3 Cell 3", 0, -1) ; next cell same line
+
 
        GUICtrlCreateLabel("Line 4 Cell 1", -3 * $widthCell, 0) ; next line Cell1
+
    GUICtrlCreateLabel("Line 1 Cell 1", 10, 30, $widthCell) ; first cell 70 width
        GUISetState()     ; will display an empty dialog box
+
    GUICtrlCreateLabel("Line 2 Cell 1", -1, 0)             ; next line
        ; Run the GUI until the dialog is closed
+
    GUICtrlCreateLabel("Line 3 Cell 2", 0, 0)               ; next line and next cell
        Do
+
    GUICtrlCreateLabel("Line 3 Cell 3", 0, -1)             ; next cell same line
            $msg = GUIGetMsg()
+
    GUICtrlCreateLabel("Line 4 Cell 1", -3 * $widthCell, 0) ; next line Cell1
        Until $msg = $GUI_EVENT_CLOSE
+
 
        $iOldOpt = Opt("GUICoordMode", $iOldOpt)
+
    GUISetState() ; will display an empty dialog box
    EndFunc  ;==>Example
+
 
 +
    ; Run the GUI until the dialog is closed
 +
    Local $msg
 +
 
 +
    Do
 +
        $msg = GUIGetMsg()
 +
    Until $msg = $GUI_EVENT_CLOSE
 +
 
 +
    Opt("GUICoordMode", $iOldOpt)
 +
EndFunc  ;==>Example
 +
</syntaxhighlight>

Revision as of 14:09, 10 November 2012

A Label is simple, plain piece of text appearing in GUI.


Summary

Label is GUI control, which consists of simple, plain piece of text. The function for creating Label is GuiCtrlCreateLabel. You can change text using GuiCtrlSetData and read it using GuiCtrlRead functions.


Example

This example demonstrates the creation of a GUI label.

 #include <GUIConstantsEx.au3>

 Opt('MustDeclareVars', 1)

 Example()

 Func Example()
     GUICreate("My GUI") ; will create a dialog box that when displayed is centered

     GUISetHelp("notepad") ; will run notepad if F1 is typed

     Local Const $iOldOpt = Opt("GUICoordMode", 2)

     Local Const $widthCell = 70

     GUICtrlCreateLabel("Line 1 Cell 1", 10, 30, $widthCell) ; first cell 70 width
     GUICtrlCreateLabel("Line 2 Cell 1", -1, 0)              ; next line
     GUICtrlCreateLabel("Line 3 Cell 2", 0, 0)               ; next line and next cell
     GUICtrlCreateLabel("Line 3 Cell 3", 0, -1)              ; next cell same line
     GUICtrlCreateLabel("Line 4 Cell 1", -3 * $widthCell, 0) ; next line Cell1

     GUISetState() ; will display an empty dialog box

     ; Run the GUI until the dialog is closed
     Local $msg

     Do
         $msg = GUIGetMsg()
     Until $msg = $GUI_EVENT_CLOSE

     Opt("GUICoordMode", $iOldOpt)
 EndFunc   ;==>Example