Jump to content

Change color multiple labels


Loc
 Share

Recommended Posts

i have more than 100 labels. when it changes color it will flash from top to bottom. how to make it recognize what color the current color is so that when changing the color it will not need to change the old color. like the function _guictrltab_setcurfocus() when i am at position 0 but i still use it at position 0, it does not change, and guictrlsetstate(, $gui_show) when it is at position 0 it still shows position 0 so it will flash. if you save its old color to a file for comparison, it's too verbose. sorry for my english not good

Link to comment
Share on other sites

  • Moderators

Loc,

Why save to a file? Why not keep the current colour value in an array during run-time? You would only need to read/save the values to file at start/end of the script.

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

My label here is the table number. It is distinguished by 3 colors. Empty table: Blue Table with people: Red Table is oder: White About the distinction to change these colors I save to file. It is working directly on the GUI so will have to check all tables to see which tables are empty, which are occupied and which are oder

Edited by Melba23
Removed image
Link to comment
Share on other sites

  • Moderators

Loc,

That sounds as if an internal array is exactly what you need. You say that it "is working directly on the GUI" - does that mean that you click on the label to change the colour? If so then all you need to do is to check the current state and advance it to the next one. I have to take my grandchildren to "cantajuegos" (songs and dances for small children) in a few minutes, but I will try and produce something to show you how I think you might proceed later this evening.

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

  • Moderators

Loc,

Try this:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

; Arrays to hold table ControlIDs and states
Global $aTables[5], $aState[5]
; Array of required colours
Global $aColours[3] = [0x0000FF, 0xFF0000, 0xFFFFFF]

$hGUI = GUICreate("Test", 500, 500)
GUISetBkColor(0xC4C4C4)

; Create the labels usign an algorithm
For $i = 0 To 4
    $aTables[$i] = GUICtrlCreateLabel($i + 1, ($i * 100) + 5, 5, 90, 90, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE))
    GUICtrlSetFont($aTables[$i], 24, 800)
    ; Ste intial colour
    GUICtrlSetColor($aTables[$i], 0xFF8000)
    GUICtrlSetBkColor($aTables[$i], $aColours[0])
Next

GUISetState()

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    ; Look for a table being clicked
    For $i = 0 To 4
        If $iMsg = $aTables[$i] Then
            ; Increase table state - using Mod automatically resets to 0 when required
            $aState[$i] = Mod($aState[$i] + 1, 3)
            ; Now set table tot he correct colour
            GUICtrlSetBkColor($aTables[$i], $aColours[$aState[$i]])
            ; No point in looking further
            ExitLoop
        EndIf
    Next
WEnd

How does that look?

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

  • Moderators

Loc,

Sorry to hear that. We will still be here when you are released.

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

  • 2 weeks later...

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