Gnat Posted August 26, 2005 Share Posted August 26, 2005 I cannot find any clues, hints or directions on how to format the text of a button. I would like to be able to format the text to be a different color, but the GUICtrlSetColor doesn't work. Any ideas? Thanx in advance. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 26, 2005 Moderators Share Posted August 26, 2005 In the help file under GUICtrlSetImage(): #include <GUIConstants.au3> GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUICtrlCreateButton ("my picture button", 10,20,40,40, $BS_ICON) GUICtrlSetImage (-1, "shell32.dll",22) GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted August 26, 2005 Share Posted August 26, 2005 I cannot find any clues, hints or directions on how to format the text of a button. I would like to be able to format the text to be a different color, but the GUICtrlSetColor doesn't work. Any ideas?Thanx in advance. <{POST_SNAPBACK}>hows about this#include <GUIConstants.au3> GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered $btn_ok = GUICtrlCreateButton ("OK", 10, 30, 50) $btn_cancel = GUICtrlCreateButton ( "Cancel", 80, 30, 50) $btn_1 = GUICtrlCreateButton("Here is one type of font", 10, 130, 200, 25) GUIctrlSetBkColor(-1, 0x0066FF) GUICtrlSetCursor(-1, 0) GUICtrlSetTip(-1, "Help tip") GUICtrlSetFont(-1, 9, 650) $btn_2 = GUICtrlCreateLabel(" here is another", 10, 200, 200, 25, $SS_SUNKEN, $WS_EX_DLGMODALFRAME) GUICtrlSetBkColor(-1, 0x0066FF) GUICtrlSetFont(-1, 14, 750) GUICtrlSetColor(-1, 0x00ff00) GUISetState () ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Or $msg = $btn_cancel Then ExitLoop If $msg = $btn_ok Or $msg = $btn_1 Or $msg = $btn_2 Then MsgBox(0,"test", "This is a button test") EndIf Wendhope it helps8) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 26, 2005 Moderators Share Posted August 26, 2005 (edited) Neat idea Valuater... I added to your $SS_CENTER $btn_2 for a cleaner look. $btn_2 = GUICtrlCreateLabel(" here is another", 10, 200, 200, 25, $SS_SUNKEN, $WS_EX_DLGMODALFRAME + $SS_CENTER) Edit: Of course that doesn't look like a button : Edited August 26, 2005 by ronsrules Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted August 27, 2005 Share Posted August 27, 2005 (edited) Neat idea Valuater...I added to your $SS_CENTER $btn_2 for a cleaner look.$btn_2 = GUICtrlCreateLabel(" here is another", 10, 200, 200, 25, $SS_SUNKEN, $WS_EX_DLGMODALFRAME + $SS_CENTER)Edit: Of course that doesn't look like a button : <{POST_SNAPBACK}>good idea to add that...by the way.... very nice avitar8)2nd by the wayI'm glad you said something to B3TAhttp://www.autoitscript.com/forum/index.php?showtopic=15155#8) Edited August 27, 2005 by Valuater Link to comment Share on other sites More sharing options...
B3TA_SCR1PT3R Posted August 30, 2005 Share Posted August 30, 2005 good idea to add that...by the way.... very nice avitar8)2nd by the wayI'm glad you said something to B3TAhttp://www.autoitscript.com/forum/index.php?showtopic=15155#8)<{POST_SNAPBACK}>ouch [right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right] Link to comment Share on other sites More sharing options...
AutoChris Posted August 30, 2005 Share Posted August 30, 2005 (edited) Actually, it would be:$btn_2 = GUICtrlCreateLabel("here is another", 10, 200, 200, 25, $SS_SUNKEN + $SS_CENTER, $WS_EX_DLGMODALFRAME) as long as we are all being pedantic. Edited August 30, 2005 by SerialKiller Link to comment Share on other sites More sharing options...
Valik Posted August 30, 2005 Share Posted August 30, 2005 Actually, it would be: as long as we are all being pedantic.<{POST_SNAPBACK}>Actually, pedantic is:$btn_2 = GUICtrlCreateLabel("here is another", 10, 200, 200, 25, BitOR($SS_SUNKEN, $SS_CENTER), $WS_EX_DLGMODALFRAME)Styles should never be added. Link to comment Share on other sites More sharing options...
AutoChris Posted September 1, 2005 Share Posted September 1, 2005 Styles should never be added.@Valik: Tell me more about this (not sarcasm). I have always added styles without any (known) problems. So instead of adding them, I should BitOR the styles? What kind of problem can adding them potentially cause? Link to comment Share on other sites More sharing options...
AutoChris Posted September 2, 2005 Share Posted September 2, 2005 3 + 2 = 7BitOr(3,2) = 3Lar.<{POST_SNAPBACK}>Thank you. I understand the concept of BitOR, BitAND, BitXOR, etc; however, I do not understand why I should BitOR the styles. Even the help file shows adding the styles together so I am not sure why adding them together would be a problem. Link to comment Share on other sites More sharing options...
Valik Posted September 2, 2005 Share Posted September 2, 2005 Styles are not significant as numeric values, they are significant in their bit patterns. If you add two styles together, it's possible in some rare situations that the results will not be the same as if they were BitOR'd. This can be a problem with some of the window styles because in reality they are more than one normal style conviently OR'd together. If you take one of these meta-styles and add one of it's composite styles by mistake, you'll produce an invalid result. However, if you BitOR two numbers and the bit patterns already match, no harm is done. Some simple and meanginless numbers to show: Local Const $Style1 = 1 Local Const $Style2 = 2 Local Const $MetaStyle = BitOR($Style1, $Style2) Local $myStyle = $MetaStyle + $Style1 ; Oops, because addition was used, this produces the bit pattern: 0100 Local $myStyle2 = BitOR($MetaStyle, $Style1) ; Okay, The lowest bit is already set so no need to set it again, bit pattern remains: 0011 Link to comment Share on other sites More sharing options...
AutoChris Posted September 2, 2005 Share Posted September 2, 2005 (edited) Styles are not significant as numeric values, they are significant in their bit patterns. If you add two styles together, it's possible in some rare situations that the results will not be the same as if they were BitOR'd. This can be a problem with some of the window styles because in reality they are more than one normal style conviently OR'd together. If you take one of these meta-styles and add one of it's composite styles by mistake, you'll produce an invalid result. However, if you BitOR two numbers and the bit patterns already match, no harm is done. Some simple and meanginless numbers to show:Local Const $Style1 = 1 Local Const $Style2 = 2 Local Const $MetaStyle = BitOR($Style1, $Style2) Local $myStyle = $MetaStyle + $Style1 ; Oops, because addition was used, this produces the bit pattern: 0100 Local $myStyle2 = BitOR($MetaStyle, $Style1) ; Okay, The lowest bit is already set so no need to set it again, bit pattern remains: 0011<{POST_SNAPBACK}>Okay! I understand the reasoning now. Thank you.Now how about some modifications to the help file examples? Edited September 2, 2005 by SerialKiller Link to comment Share on other sites More sharing options...
Valik Posted September 2, 2005 Share Posted September 2, 2005 Point out (in a bug reports thread) all locations you see them being added. They are correct in some places but I guess wrong in others. They will be fixed if somebody points out where they are specifically. 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