Jump to content

Button help


Gnat
 Share

Recommended Posts

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:

Link to comment
Share on other sites

  • Moderators

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

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

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

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

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.
Link to comment
Share on other sites

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

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...