Sign in to follow this  
Followers 0
Achilles

Setting the bk color of a hidden slider not working right

4 posts in this topic

Setting the bk color of a showing slider works fine. When the slider is hidden it doesn't redraw the item so the slider, when shown, has the previous background color which updates as soon as you click on the slider... Is there a way to make it redraw when it's hidden?

For example, this starts off black, do the following to see the error: Click the hide button to hide the slider, then change the background, then show the slider...

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>

$color = 0
$showing = True

GUICreate('Slider', 300, 100) ; will create a dialog box that when displayed is centered
    GUISetBKColor($color)

$slider = GUICtrlCreateSlider(10, 10, 280, 30, $TBS_HORZ + $TBS_NOTICKS)
    GUICtrlSetBkColor(-1, $color)
$btn = GUICtrlCreateButton('Switch BK color', 10, 50, 135, 25)
$btn2 = GUICtrlCreateButton('Hide/Show slider', 155, 50, 135, 25)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $btn
            If $color = 0 then 
                $color = '0xFFFFFF' 
            Else 
                $color = 0 
            EndIf 
            GUISetBkColor($color) 
            GUICtrlSetBkColor($slider, $color)
        Case $btn2 
            $showing = Not $showing 
            If $showing then 
                GUICtrlSetState($slider, $GUI_SHOW) 
            Else 
                GUICtrlSetState($slider, $GUI_HIDE)
            EndIf
        Case $GUI_EVENT_CLOSE 
            Exit 
    EndSwitch
WEnd

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites



Setting the bk color of a showing slider works fine. When the slider is hidden it doesn't redraw the item so the slider, when shown, has the previous background color which updates as soon as you click on the slider... Is there a way to make it redraw when it's hidden?

For example, this starts off black, do the following to see the error: Click the hide button to hide the slider, then change the background, then show the slider...

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>

$color = 0
$showing = True

GUICreate('Slider', 300, 100); will create a dialog box that when displayed is centered
    GUISetBKColor($color)

$slider = GUICtrlCreateSlider(10, 10, 280, 30, $TBS_HORZ + $TBS_NOTICKS)
    GUICtrlSetBkColor(-1, $color)
$btn = GUICtrlCreateButton('Switch BK color', 10, 50, 135, 25)
$btn2 = GUICtrlCreateButton('Hide/Show slider', 155, 50, 135, 25)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $btn
            If $color = 0 then 
                $color = '0xFFFFFF' 
            Else 
                $color = 0 
            EndIf 
            GUISetBkColor($color) 
            GUICtrlSetBkColor($slider, $color)
        Case $btn2 
            $showing = Not $showing 
            If $showing then 
                GUICtrlSetState($slider, $GUI_SHOW) 
            Else 
                GUICtrlSetState($slider, $GUI_HIDE)
            EndIf
        Case $GUI_EVENT_CLOSE 
            Exit 
    EndSwitch
WEnd
What about as soon as the slider is $GUI_SHOW, use GUICtrlSetBkColor($slider, $color) then.

Case $btn2
            $showing = Not $showing
            If $showing then
                GUICtrlSetState($slider, $GUI_SHOW)
                GUICtrlSetBkColor($slider, $color)
            Else
                GUICtrlSetState($slider, $GUI_HIDE)
            EndIf

Share this post


Link to post
Share on other sites

You were right.

On my xp, I could not set the background color of a hidden slider.

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  
Followers 0