1. How to create and color label borders.
2. How to use the styles FRAMES - $SS_BLACKFRAME and RECTANGLES - $SS_BLACKRECT to display text.
3. How to create a sunken in and rasied up label.
There are 15 example labels that can be easily modified and incorporated into your projects.
I'm trying to simplify the label examples to make them easier to modify and incorporate into your projects.
Update: 9/25/2008 v1.1 --- Added the Function Multi-use - with examples.
Update: 9/26/2008 v1.1 --- Added hide/show label (not working right)
If you have comments or suggestions to make better or easier labels reply away!
XampLabel Styles version 1.1
Plain Text
#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Main() Func Main() Local $msg GUICreate("XampLabel Styles v1.1"); will create a dialog box that when displayed is centered GUISetState() _GUICtrlLabel_ControlStyles() $lb1 = _GUICtrlLabel_ControlStylesMulti("Testing Func 123", 250, 125, 100, 100, $SS_BLACKFRAME, -1, -1, -1, -1, -1, -1) GUICtrlSetColor(-1, 0xff0000) $lb2 = _GUICtrlLabel_ControlStylesMulti("Testing Func 456", 185, 275, 100, 100, $SS_GRAYFRAME, $SS_SUNKEN, -1, -1, -1, 0xF098FF, _ -1) $lb3 = _GUICtrlLabel_ControlStylesMulti("Testing Func 789", 290, 275, 100, 100, $SS_ETCHEDFRAME, $SS_RIGHT, -1, -1, -1, 0xDC00FF, _ -1) ;$lb1 = _GUICtrlLabel_ControlStylesMulti("Testing Func 321", 250, 125, 100, 100, $SS_BLACKFRAME, -1, -1, -1, -1, -1, $GUI_HIDE) ;GUICtrlSetColor(-1, 0xff0000) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc Func _GUICtrlLabel_ControlStyles() #cs In this function learn the proper use of the label Control Styles. Some of them can be tricky to get to work correctly when added to your script. These 15 examples illustrates how to properly use them. #ce ;EXAMPLE 1: Label with no controls or styles GUICtrlCreateLabel("Label Created No Controls or Styles.", 10, 10, 170, 15) ;EXAMPLE 2: Label with $BlackFramed & text aligned $SS_LEFT GUICtrlCreateLabel("", 10, 30, 170, 20, $SS_BLACKFRAME);Label set to $SS_BLACKFRAME GUICtrlCreateLabel("Text Align Left.", 10 + 2, 30 + 2, 170 - 4, 20 - 4, $SS_LEFT);Label set smaller on top ;of $SS_BLACKFRAME & text aligned $SS_LEFT ;EXAMPLE 3: Label with $SS_ETCHEDFRAME & text aligned $SS_CENTER GUICtrlCreateLabel("", 10, 60, 170, 20, $SS_ETCHEDFRAME) GUICtrlCreateLabel("Text Align Center.", 10+2, 60+2, 170-4, 20-4, $SS_CENTER) ;EXAMPLE 4: Label with text aligned right & $SS_SUNKEN GUICtrlCreateLabel("Text Align Right.", 10, 90, 170, 20, $SS_RIGHT + $SS_SUNKEN) ;EXAMPLE 5:Label with $SS_GRAYRECT & $SS_LEFTNOWORDWRAP & $SS_NOPREFIX GUICtrlCreateLabel("", 10, 115, 170, 20, $SS_GRAYRECT) GUICtrlCreateLabel('We now see how the $SS_GRAYRECT & $SS_GRAYRECT & $SS_NOPREFIX works.', _ 10+1, 115+1, 170-2, 20-2, $SS_LEFTNOWORDWRAP + $SS_NOPREFIX) ;EXAMPLE 6: Label with $SS_ETCHEDHORZ GUICtrlCreateLabel('', 10, 140, 170, 35, $SS_ETCHEDHORZ) GUICtrlCreateLabel('Text RightJust: we can now see how the alignment "RightJust" works.', _ 10+1, 140+1, 170-2, 35-2, $SS_RIGHTJUST, $WS_EX_DLGMODALFRAME) ;EXAMPLE 7: Label with $SS_SIMPLE GUICtrlCreateLabel('$SS_SIMPLE: single line text only.', 10, 180, 170, 20, $SS_SIMPLE, $WS_EX_CLIENTEDGE) ;EXAMPLE 8: Label with $SS_NOPREFIX & $WS_EX_STATICEDGE & $WS_EX_OVERLAPPEDWINDOW GUICtrlCreateLabel('$WS_EX_STATICEDGE & $WS_EX_OVERLAPPEDWINDOW', 10, 210, 170, 30, $SS_NOPREFIX, _ BitOr($WS_EX_STATICEDGE, $WS_EX_OVERLAPPEDWINDOW)) ;EXAMPLE 9: Label with $SS_CENTER & $SS_NOPREFIX & $WS_BORDER GUICtrlCreateLabel('$SS_CENTER & $SS_NOPREFIX & $WS_BORDER', 10, 250, 170, 30, BitOr($SS_CENTER, $SS_NOPREFIX, $WS_BORDER)) ;EXAMPLE 10: Label with $WS_DISABLED & $WS_DLGFRAME GUICtrlCreateLabel('$WS_DISABLED + $WS_DLGFRAME', 10, 290, 170, 35, $WS_DISABLED + $WS_DLGFRAME) ;EXAMPLE 11: Label with $WS_THICKFRAME GUICtrlCreateLabel('$WS_THICKFRAME', 10, 330, 170, 35, $WS_THICKFRAME) ;EXAMPLE 12: Label with $WS_SIZEBOX GUICtrlCreateLabel('$WS_SIZEBOX', 210, 10, 170, 20, $WS_SIZEBOX) GUICtrlSetBkColor(-1, 0xFFFF00) ;EXAMPLE 13: Label with $WS_SIZEBOX & Color Border GUICtrlCreateLabel('', 210, 35, 170, 25, $WS_SIZEBOX) GUICtrlSetBkColor(-1, 0xEBD3D3) GUICtrlCreateLabel('$WS_SIZEBOX', 210+6, 35+6, 170-12, 25-12) GUICtrlSetBkColor(-1, 0xF7EEEE) ;EXAMPLE 14: Label with Thin Color Border GUICtrlCreateLabel('', 210, 65, 170, 25) GUICtrlSetBkColor(-1, 0xFFA800) GUICtrlCreateLabel('Thin Color Border', 210+1, 65+1, 170-2, 25-2) GUICtrlSetBkColor(-1, 0xFFE5B4) ;EXAMPLE 15: Label with Thick Color Border GUICtrlCreateLabel('', 210, 95, 170, 25) GUICtrlSetBkColor(-1, 0x00F2FF) GUICtrlCreateLabel('Thick Color Border', 210+3, 95+3, 170-6, 25-6) GUICtrlSetBkColor(-1, 0xC5FCFF) EndFunc Func _GUICtrlLabel_ControlStylesMulti($LB_txtb, $LB_lft, $LB_top, $LB_wth, $LB_hgt, $LB_stla, $LB_stlb, $LB_etla, $LB_etlb, _ $LB_cola, $LB_colb, $LB_sta) #cs To use multiple instances of the same label or multiple labels with Different Control Styles and Differnet Locations. Now supports "ALL LABEL" Control Styles! Some examples: $SS_BLACKFRAME, $SS_GRAYFRAME, $SS_WHITEFRAME, $SS_BLACKRECT, $SS_GRAYRECT, $SS_WHITERECT, SS_ETCHEDHORZ, $SS_ETCHEDVERT, $SS_ETCHEDFRAME is demostrated below with a function. For this function I'm trying to figure out a work around for: 1. hide/show if you show label then cant hide & want work with varible $LB_1 but will work with -1 2. change information can chage data use -1 but want change if use varible $LB_1 Solution: use of a ini file read/right #ce GUICtrlCreateLabel("", $LB_lft, $LB_top, $LB_wth, $LB_hgt, $LB_stla, $LB_etla) GUICtrlSetBkColor(-1, $LB_cola) GUICtrlSetState(-1, $LB_sta) ;GUICtrlSetData(-1, $LB_txta) GUICtrlCreateLabel($LB_txtb, $LB_lft+2, $LB_top+2, $LB_wth-4, $LB_hgt-4, $LB_stlb, $LB_etlb) GUICtrlSetBkColor(-1, $LB_colb) GUICtrlSetState(-1, $LB_sta) GUICtrlSetData(-1, $LB_txtb) EndFunc Func _GUICtrlLabel_ControlStylesVarib() #cs Use varibles as multi use or...more details coming after further research and experiments I'll post the results! #ce Local $LB1a_txt = "", $LB1a_lft = "10", $LB1a_top = "30", $LB1a_wth = "170", $LB1a_hgt = "20", _ $LB1a_stl = $SS_BLACKFRAME, $LB1a_etl = "" Local $LB1b_txt = "Text Align Left.", _ $LB1b_lft = $LB1a_lft+2, $LB1b_top = $LB1a_top+2, $LB1b_wth = $LB1a_wth-4, $LB1b_hgt = $LB1a_hgt-4, _ $LB1b_stl = $SS_LEFT, $LB1b_etl = "" GUICtrlCreateLabel($LB1a_txt, $LB1a_lft, $LB1a_top, $LB1a_wth, $LB1a_hgt, $LB1a_stl);Label set to $SS_BLACKFRAME GUICtrlCreateLabel($LB1b_txt, $LB1b_lft, $LB1b_top, $LB1b_wth, $LB1b_hgt, $LB1b_stl);Label set smaller on top ;of $SS_BLACKFRAME & text aligned $SS_LEFT EndFunc
Learning to write scripts,
jfcby
Edited by jfcby, 26 September 2008 - 07:41 PM.






