Function Reference


GUICtrlCreateLabel

Creates a static Label control for the GUI.

GUICtrlCreateLabel ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text The text of the control.
left The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width [optional] The width of the control (default text autofit in width).
height [optional] The height of the control (default text autofit in height).
style [optional] Defines the style of the control. See GUI Control Styles Appendix.
default ( -1) : none.
forced styles : $SS_NOTIFY, $SS_LEFT
exStyle [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: the identifier (controlID) of the new control.
Failure: 0.

Remarks

To set or change information in the control see GUICtrlUpdate...() functions.

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_LABEL, newstyle, ... ).
To use the values specified above you must #include <StaticConstants.au3> in your script.

Default resizing is $GUI_DOCKAUTO size and position will occur.

The extended style $GUI_WS_EX_PARENTDRAG can be used to allow the dragging of the parent window for windows that don't have a titlebar (no $WS_CAPTION style in GUICreate()).

To set the background to transparent, use GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT).

If you really need to create a label that overlap other control you can set the style to $WS_CLIPSIBLINGS.
In fact that has a little performance drawback as mention see $WS_CLIPSIBLINGS forum.

Related

GUICoordMode (Option), GUICtrlUpdate..., GUIGetMsg

Example

Example 1

#include <GUIConstantsEx.au3>
Example()
Func  Example()
GUICreate ("My GUI"); will create a dialog box that when displayed is centered
GUISetHelp ("notepad.exe"); will run notepad if F1 is typed
Local $iOldOpt= Opt ("GUICoordMode",2)
Local $iWidthCell= 70
GUICtrlCreateLabel ("Line 1 Cell 1",10,30,$iWidthCell); 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* $iWidthCell,0); next line Cell1
GUISetState (@SW_SHOW ); will display an empty dialog box
; Loop until the user exits.
While 1
Switch GUIGetMsg ()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
$iOldOpt= Opt ("GUICoordMode",$iOldOpt)
EndFunc ;==>Example

GUICtrlCreateLabel() overlapping controls

#include <GUIConstantsEx.au3>
#include <WindowsStylesConstants.au3>
Local $hGUI= GUICreate ("Example",300,200)
Local $idLabel= GUICtrlCreateLabel (" Label overlapping the whole client area",0,0,300,200,$WS_CLIPSIBLINGS)
; $WS_CLIPSIBLINGS imply a small perf drawback
; see ​https://social.msdn.microsoft.com/Forums/en-US/dcd6a33c-2a6f-440f-ba0b-4a5fa26d14bb/when-to-use-wsclipchildren-and-wsclipsibilings-styles?forum=vcgeneral
; better to not overlap controls
;~ Local $idLabel = GUICtrlCreateLabel(" Label NOT OVERLAPPING others controls", 0, 0, 290, 170)
Local $idBtn_Close= GUICtrlCreateButton ("Close",210,170,85,25)
GUICtrlSetState (-1,$GUI_ONTOP)
GUISetState ()
While True
Switch GUIGetMsg ()
Case $GUI_EVENT_CLOSE,$idBtn_Close
ExitLoop
Case $idLabel
ConsoleWrite ("Label"&@CRLF )
EndSwitch
WEnd

AltStyle によって変換されたページ (->オリジナル) /