Jump to content
Sign in to follow this  
jmosley708

GetBkColor from control

Recommended Posts

jmosley708

I've created some buttons and I've used guictrlsetbkcolor to change their colors. I want to make the buttons flash two alternating colors, but I want to alternate with the exsisting color to another color. There is no command to get the bkcolor and I don't want to use pixelsearch, because I would have to know the coordinates for the buttons. Is there another way to get the background color from the button?

Share this post


Link to post
Share on other sites
rasim

I've created some buttons and I've used guictrlsetbkcolor to change their colors. I want to make the buttons flash two alternating colors, but I want to alternate with the exsisting color to another color. There is no command to get the bkcolor and I don't want to use pixelsearch, because I would have to know the coordinates for the buttons. Is there another way to get the background color from the button?

Hi! 2 examples:

get color:

#include <GUIConstantsEx.au3>

Opt("PixelCoordMode", 2)

$hGUI = GUICreate("Get button color", 200, 100)

$button = GUICtrlCreateButton("Test", 60, 20, 75, 23)
GUICtrlSetBkColor(-1, 0xFF0000) ;red color

$GetColor_Button = GUICtrlCreateButton("Get", 60, 60, 75, 23)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GetColor_Button
            $aPos = ControlGetPos($hGUI, "", $button)
            $Color = PixelGetColor($aPos[0] + 3, $aPos[1] + 3)
            $Color = "0x" & Hex($Color, 6)
            MsgBox(0, "Color", $Color)
    EndSwitch
WEndoÝ÷ ÙÈZ¢Z+jëh×6#include <GUIConstantsEx.au3>

Global $color = 0xFF0000

Opt("PixelCoordMode", 2)

$hGUI = GUICreate("Get button color", 200, 100)

$button = GUICtrlCreateButton("Test", 60, 40, 75, 23)
GUICtrlSetBkColor(-1, $color)

GUISetState()

AdlibEnable("_SetColor", 500)

Do
Until GUIGetMsg() = -3

Func _SetColor()
    $color = BitNOT($color)
    GUICtrlSetBkColor($button, $color)
EndFunc

muttley

Share this post


Link to post
Share on other sites
crzftx

$color = 0xFFFFFF - $color

That changes the color to it's inverse each time, instead of to black...

I would probably use 2 separate colors.

#include <GUIConstantsEx.au3>

Global $color = 0xFF0000

Opt("PixelCoordMode", 2)

$hGUI = GUICreate("Get button color", 200, 100)

$button = GUICtrlCreateButton("Test", 60, 40, 75, 23)
GUICtrlSetBkColor(-1, $color)

GUISetState()

AdlibEnable("_SetColor", 500)

Do
Until GUIGetMsg() = -3

Func _SetColor()
    If $color = 0xFF0000 Then
        $color = 0x00FF00
    Else
        $color = 0xFF0000
    EndIf
    GUICtrlSetBkColor($button, $color)
EndFunc

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

why is it so hard to implement ...getbkColor functions?

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.