Jump to content

_ChooseColor problem!


Achilles
 Share

Recommended Posts

Hello... as you see when you click on any of the top three buttons it brings up the choose color box.

The problem is:

Once you have changed the label color, if you go to change it again and push cancel it goes back to black instead of staying the color you left it before.

For the label, if you push cancel the label will then become the same background as the rest of the box.

#include <GUIConstants.au3>
#include <Misc.au3>
$color = 0x6F8BFD
$color2 = 0x6F8BFD
$maincolor = 0xD0D3FB
$maincolor2 = 0xD0D3FB
$lcolor = 0
$lcolor2 = 0
$colorchange = GuiCreate("Color Properties", 300, 390)
        GUISetBkColor ($color)
    $bkcolor = GuiCtrlCreateButton("Change background", 10, 10, 280, 25)
    $lbcolor = GuiCtrlCreateButton("Change label color", 10, 45, 280, 25)
    $amaincolor = GuiCtrlCreateButton("Change list color", 10, 80, 280, 25)
    $samplelabel = GuiCtrlCreateLabel("This will be the color of you label", 10, 300, 290, 25, $SS_CENTER)
        GUICtrlSetColor(-1,$lcolor)
    $samplemain = GuiCtrlCreateLabel("", 70, 120, 160, 160, "", $WS_EX_STATICEDGE)
        GuiCtrlSetBkColor(-1, $maincolor)
    $ok = GuiCtrlCreateButton("OK", 40, 340, 80, 30)
    $cancel = GuiCtrlCreateButton("Cancel", 180, 340, 70, 30)
    GuiSetState()
    
    While 1
        $ms = GuiGetMsg()
            If $ms = $GUI_EVENT_CLOSE then Exit
            If $ms = $cancel then Exit
            If $ms = $bkcolor then 
                $color2 = _ChooseColor (2, $color, 2)
                If (@error) then $color = $color2
                $color = $color2
                GUISetBkColor($color2)
                Endif
            If $ms = $lbcolor then 
                $lcolor2 = _ChooseColor (2, $lcolor, 2)
                If (@error) then $lcolor = $lcolor2
                
                GUICtrlSetColor($samplelabel, $lcolor2)
                $lcolor2 = $lcolor
                $lcolor = $lcolor2
                Endif
            If $ms = $amaincolor then 
                $maincolor2 = _ChooseColor (2, $maincolor, 2)
                If (@error) then $maincolor = $maincolor2
                GuiCtrlSetBkColor($samplemain, $maincolor2)
                $maincolor = $maincolor2
                Endif
            If $ms <> $bkcolor Then $color = $color2    
            If $ms <> $maincolor Then $maincolor = $maincolor2
            If $ms = $ok Then
                GuiCtrlSetState($slider, $GUI_Disable)
                GUICtrlSetColor($currentsong, $lcolor2)
                GUICtrlSetColor($volumelabel, $lcolor2)
                GUICtrlSetColor($searchlabel, $lcolor2)
                GUICtrlSetBkColor($main, $maincolor2)
                GUISetBkColor($color2, $wholegui)
                $color = $color2
                $lcolor = $lcolor2
                $maincolor = $maincolor2
                GuiCtrlSetState($slider, $GUI_Enable)
                GuiDelete($colorchange)
                Exitloop
                Endif
    Wend

I know it's probably some stupid little mistake, but I've trying for quite a while to fix this to no avail.

Any help greatly appreciated,

Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

  • Moderators

This doesn't make much sense:

If (@error) then $color = $color2
                $color = $color2
You're making it the same color whether it's at error or not... sorry didn't look past that line.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

What smoke said and a few other problems, reformated it for readability:

#include <GUIConstants.au3>
#include <Misc.au3>
$color = 0x6F8BFD
$maincolor = 0xD0D3FB
$lcolor = 0
$colorchange = GUICreate("Color Properties", 300, 390)
GUISetBkColor($color)
$bkcolor = GUICtrlCreateButton("Change background", 10, 10, 280, 25)
$lbcolor = GUICtrlCreateButton("Change label color", 10, 45, 280, 25)
$amaincolor = GUICtrlCreateButton("Change list color", 10, 80, 280, 25)
$samplelabel = GUICtrlCreateLabel("This will be the color of you label", 10, 300, 290, 25, $SS_CENTER)
GUICtrlSetColor(-1, $lcolor)
$samplemain = GUICtrlCreateLabel("", 70, 120, 160, 160, "", $WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, $maincolor)
$ok = GUICtrlCreateButton("OK", 40, 340, 80, 30)
$cancel = GUICtrlCreateButton("Cancel", 180, 340, 70, 30)
GUISetState()

While 1
    $ms = GUIGetMsg()
    Switch $ms
        Case $GUI_EVENT_CLOSE, $cancel
            Exit
        Case $bkcolor
            $tcolor = _ChooseColor(2, $color, 2)
            If (@error) Then ContinueLoop
            $color = $tcolor
            GUISetBkColor($color)
        Case $lbcolor
            $tcolor = _ChooseColor(2, $lcolor, 2)
            If (@error) Then ContinueLoop
            $lcolor = $tcolor
            GUICtrlSetColor($samplelabel, $lcolor)
        Case $amaincolor
            $tcolor = _ChooseColor(2, $maincolor, 2)
            If (@error) Then ContinueLoop
            $maincolor = $tcolor
            GUICtrlSetBkColor($samplemain, $maincolor)
        Case $ok
            GUICtrlSetState($slider, $GUI_Disable)
            GUICtrlSetColor($currentsong, $lcolor2)
            GUICtrlSetColor($volumelabel, $lcolor2)
            GUICtrlSetColor($searchlabel, $lcolor2)
            GUICtrlSetBkColor($main, $maincolor2)
            GUISetBkColor($color2, $wholegui)
            $color = $color2
            $lcolor = $lcolor2
            $maincolor = $maincolor2
            GUICtrlSetState($slider, $GUI_Enable)
            GUIDelete($colorchange)
            ExitLoop
    EndSwitch
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

This doesn't make much sense:
If (@error) then $color = $color2
                $color = $color2oÝ÷ Ù.ßÚÞ©"­¶¬jg¢Z+­êâ·lj׫®è®z-²ëÉØm$¥«-¶­)Þþ«¨µæØZK~à¢Ö¢ëm«G£¯z»ajÝý²z-¶©j»m«b²}ý·
+)à"Ýý²Ø^¥ªíiû^®ØZ¶f¢ºÚ"µÍBBRY ÌÍÛÈH   ÌÍÛÛÛÜ[BBBIÌÍÛÛÛÜHÐÚÛÜÙPÛÛÜ
    ÌÍÛÛÛÜBBBBRY
ÜH[    ÌÍÛÛÛÜH   ÌÍÛÛÛÜBBBQÕRPÝÙ]ÛÛÜ ÌÍÜØ[[X[    ÌÍÛÛÛÜBBBBIÌÍÛÛÛÜH  ÌÍÛÛÛÜBBBQ[Y

I don't know why that doesn't work...

Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

What smoke said and a few other problems, reformated it for readability:

#include <GUIConstants.au3>
#include <Misc.au3>
$color = 0x6F8BFD
$maincolor = 0xD0D3FB
$lcolor = 0
$colorchange = GUICreate("Color Properties", 300, 390)
GUISetBkColor($color)
$bkcolor = GUICtrlCreateButton("Change background", 10, 10, 280, 25)
$lbcolor = GUICtrlCreateButton("Change label color", 10, 45, 280, 25)
$amaincolor = GUICtrlCreateButton("Change list color", 10, 80, 280, 25)
...............
.....

YAY, thank you very much. I didn't see your post earlier.

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
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...