Jump to content
Sign in to follow this  
Knight

GUICtrlSetBkColor() back to default window color?

Recommended Posts

Knight

Hi,

I did a quick search and was unable to find anything, perhaps my keywords were no good.

I have scripted an application that will change a Label's BK color to green when a button is pressed and all works fine. Now I would like to be able to set the Bk color back to default later in the script. I figure I could just delete the label and re-write it, but I was hoping there was a better way. Any help is much appreciated.

Share this post


Link to post
Share on other sites
KaFu

Upsa, misread that you search for guibkcolor... left both gui and ctrl bk color examples in :(...

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

Local $msg

GUICreate("My GUI") ; will create a dialog box that when displayed is centered
GUISetBkColor(0x00ff00)
$label = GUICtrlCreateLabel("Test",10,10,200)
GUICtrlSetBkColor(-1,0x0000ff)
GUISetState(@SW_SHOW) ; will display an empty dialog box
Sleep(2000)

GUISetBkColor(_GetSysColor(15))
GUICtrlSetBkColor($label,_GetSysColor(15))


While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

Func _RGB2BGR($nColor)
    Return (BitAND($nColor, 0xff) * 0x10000) + BitAND($nColor, 0xff00) + (BitAND($nColor, 0xff0000) / 0x10000)
EndFunc   ;==>_RGB2BGR

Func _GetSysColor($nIndex)
    Return _RGB2BGR(_WinAPI_GetSysColor($nIndex))
EndFunc   ;==>_GetSysColor
  • Like 1

Share this post


Link to post
Share on other sites
Knight

Upsa, misread that you search for guibkcolor... left both gui and ctrl bk color examples in :(...

..

Works great. Thanks a lot KaFu.

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  

×