Jump to content

Background color on label does not update


barrikid
 Share

Recommended Posts

I am not able to update the color of a label after it has been set.

Here is just a snippet, I just took fragments of the code

GUICreate("Gui", 500, 500, 0, 0)

$lCityName = GUICtrlCreateLabel("", 10, 60, 50, 50)
GUICtrlSetBkColor($lCityName, $white) ;Defined white and black earlier

GUISetState()

While 1

        $msg = GUIGetMsg()
        
    If $msg = $GUI_EVENT_PRIMARYDOWN Then
        GUICtrlSetBkColor($lCityName, $black)
    EndIf

Wend

I am able to set the color up top, but not during the loop, any reason why?

Thanks,

BK

Link to comment
Share on other sites

I am not able to update the color of a label after it has been set.

Here is just a snippet, I just took fragments of the code

GUICreate("Gui", 500, 500, 0, 0)

$lCityName = GUICtrlCreateLabel("", 10, 60, 50, 50)
GUICtrlSetBkColor($lCityName, $white) ;Defined white and black earlier

GUISetState()

While 1

 $msg = GUIGetMsg()
        
    If $msg = $GUI_EVENT_PRIMARYDOWN Then
        GUICtrlSetBkColor($lCityName, $black)
    EndIf

Wend

I am able to set the color up top, but not during the loop, any reason why?

Thanks,

BK

; *** Start added by AutoIt3Wrapper ***
#include <GUIConstantsEx.au3>
; *** End added by AutoIt3Wrapper ***
#AutoIt3Wrapper_Add_Constants=n

GUICreate("Gui", 500, 500, 0, 0)

$lCityName = GUICtrlCreateLabel("", 10, 60, 50, 50)
GUICtrlSetBkColor($lCityName, 0xffffff) 

GUISetState()

While 1

    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_PRIMARYDOWN Then
    GUICtrlSetBkColor($lCityName, 0)
    EndIf
    if $msg = -3 then Exit

Wend

works fine so I think something else is wrong.

I think it is more sensible to post exactly the code you are having problems with, code which we can run, and especially don't post code that doesn't show what you are talking about so that we reach a conclusion more efficiently. ( Or in other words, so we don't waste our time:)).

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • Moderators

barrikid,

Works for me - does it not work for you? ;)

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$lCityName = GUICtrlCreateLabel("", 10, 60, 50, 50)
GUICtrlSetBkColor($lCityName, 0xFF0000)

GUISetState()

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            GUICtrlSetBkColor($lCityName, 0x0000FF)
    EndSwitch
WEnd

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

barrikid,

I cannot imagine how Win7 would prevent that script from working. ;)

Have you tried rebooting your machine and then running the script again? :)

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

I have a hunch it's in the way you declared your colors, of course it's a guess because you didn't post the declarations for the colors.

$Black = 0x000000 is correct, whereas $Black = "0x000000" is incorect.

The colors are already inside ColorConstants.au3 so why not use them? This works fine and all I've done is change your color variables to the correct names as used in the constants file.

#Include<ColorConstants.au3>
#Include<GuiConstants.au3>
GUICreate("Gui", 500, 500, 0, 0)

$lCityName = GUICtrlCreateLabel("", 10, 60, 50, 50)
GUICtrlSetBkColor($lCityName, $Clr_White) ;Defined white and black earlier

GUISetState()

While 1

        $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_PRIMARYDOWN Then
        GUICtrlSetBkColor($lCityName, $Clr_Black)
    EndIf
    If $Msg = -3 Then Exit
Wend

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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