jfcby Posted September 25, 2008 Share Posted September 25, 2008 (edited) When I was working on a project trying to find examples of label styles to learn how to use them because the Help File and the forum did not provide that many examples for most of the styles that I found and wanted to use. So I asked a few questions on the forum and experimented with the controls and styles and now I want to share with you what I've learned for a reference and a simple learning tool. 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.1expandcollapse popup#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 September 26, 2008 by jfcby Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB **** Link to comment Share on other sites More sharing options...
jfcby Posted September 26, 2008 Author Share Posted September 26, 2008 (edited) XampLabel Styles version 1.0 now...Updated: 9/25/2008 to version 1.1 by adding the Function Multi-use with examples with the help of SmOKe_N code.SEE post #1 for updated code.Learning to write code,jfcby Edited September 26, 2008 by jfcby Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB **** Link to comment Share on other sites More sharing options...
jfcby Posted September 26, 2008 Author Share Posted September 26, 2008 XampLabel Styles version 1.1Update: 9/26/2008 v1.1 --- Added hide/show label (not working right)For the function below I'm trying to figure out a work around for 1. If the label is showing when the program starts I can't figure out how to hide it in the script using a variable.2. Can't figure out how to change the data of the label using a variable. I think that I might be able to get this to work using a ini file but I'd rather not if there is another way.If you have comments or suggestions to make better or easier labels reply away all help is appreciated!expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Local $msg GUICreate("XampLabel Styles v1.1"); will create a dialog box that when displayed is centered GUISetState() $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) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd 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) 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 Learning to write scripts,jfcby Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB **** Link to comment Share on other sites More sharing options...
CodyBarrett Posted June 24, 2009 Share Posted June 24, 2009 looks pretty decent so far [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Valuater Posted June 24, 2009 Share Posted June 24, 2009 looks pretty decent so farUmmm, That's from 'almost' a year ago... 8) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now