Jump to content

Buttons / change style and color


Recommended Posts

Hello,

I think this is already solved, as I image I not the first one, but sorry I was not able to get a helping post (or manual entry).

Could someone please so kind to guide me to the solution (link, page ?)

Let me explain my problem:

I created a menu of buttons, dynamical changing text is displayed after the user pressed a button. A top menu is displaying 8 buttons, than user presses button 2 and the sub menu 2 consisting of again of several buttons is displayed. So actually I got two button types, one is referring to a sub menu and the other type is for EXECUTING something. To show this difference to the user I choose to have different colours.

Up to this point everything is working perfect, but I'm not able to set Color to the buttons without "removing" the style, and setting the Style removes the colour....

I created a abstract example to show you my issue:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
Opt('MustDeclareVars', 0)

dim $testbutton[5]
Consolewrite(@AutoItVersion)
GUICreate("My GUI style")  ; will create a dialog box that when displayed is centered
    for $i=1 to 4
        $testbutton[$i]=GUICtrlCreateButton("Test",10,10+(30*$i),100,30,$BS_RIGHT)
    Next
Example()


Func Example()
    Local $msg

    for $i=1 to 4
        GUICtrlSetBkColor($testbutton[$i],0x88bbff)
        GUICtrlSetStyle($testbutton[$i], $BS_RIGHT)
    Next

    
    
    GUISetState()

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example

In the example based on the manual I create 4 buttons and later I want to change the colour. If I start the script with the code above, the text is only right justified and the button background is default windows. By remarking the line 20 (GUICtrlSetStyle($testbutton[$i], $BS_RIGHT)) the colour is correct but the text is now in the center.

How does these tow features work together? Is it possible? I know the manual states, that some objects can't be modified, but as I saw that each line for itself is working why not together?

If you post me a link or a post number I really appreciated your effort. Thank you.

(PS: BTW: No setting the color and style on GUICtrlCreateButton line is not an option, because I want to have the buttons dynamical changed)

Link to comment
Share on other sites

  • Moderators

Tankbuster,

As was discussed recently in this topic, it seems that you cannot combine button colours and styles. :idea:

There is also a longstanding bug #376 regarding coloured buttons trapping the Enter key, so I try to avoid them.

Sorry to be so negative - I will try to be more helpful next time! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Sorry to be so negative - I will try to be more helpful next time! :idea:

M23

In fact this is very helpful, at least I could close the try and search way :-)

Next time I will search the bug list (I promise......note it to my-self-bug-list ...hahaha)

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