Jump to content
Sign in to follow this  
Gnat

Button help

Recommended Posts

Gnat

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. :whistle:

Share this post


Link to post
Share on other sites
SmOke_N

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.

Share this post


Link to post
Share on other sites
Valuater

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.  :whistle:

<{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
Wend

hope it helps

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
SmOke_N

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 : :whistle:

Edited 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.

Share this post


Link to post
Share on other sites
Valuater

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 :  :whistle:

<{POST_SNAPBACK}>

good idea to add that...

by the way.... very nice avitar

8)

2nd by the way

I'm glad you said something to B3TA

http://www.autoitscript.com/forum/index.php?showtopic=15155#

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
AutoChris

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 by SerialKiller

Share this post


Link to post
Share on other sites
Valik

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.

Share this post


Link to post
Share on other sites
AutoChris

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?

Share this post


Link to post
Share on other sites
AutoChris

3 + 2 = 7

BitOr(3,2) = 3

Lar.

<{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.

Share this post


Link to post
Share on other sites
Valik

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

Share this post


Link to post
Share on other sites
AutoChris

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? :whistle:

Edited by SerialKiller

Share this post


Link to post
Share on other sites
Valik

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.