Jump to content

Enable/Change Control using BIT


Hobbyist
 Share

Recommended Posts

Here is a working example of WHAT I DON'T KNOW how to do.

The desired results are to have a Button change color based upon what a Listview does (its state).
In this case the Button would turn "white" if its associated Listview becomes enabled (or perhaps shown).

In this script, after initializing, click on the Buttons to change Listviews (from 1 to 2 and/or back).
A Button, upon clicking, should turn white ONLY is the associated Listview is enabled, BUT in my case here they still turn white regardless. The buttons turn white even when the Listview is disabled.  

#include <ButtonConstants.au3>
#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiButton.au3>







$main = GUICreate(" Board", 680, 515, 150, 100)


$List2 = GUICtrlCreateListView("list2", 172, 72, 500, 260, $LVS_SINGLESEL, $LVS_EX_GRIDLINES + $LVS_EX_FULLROWSELECT) ;Spending Log
;GUICtrlSetState($List2, $GUI_disABLE)
GUICtrlSetState($List2, $GUI_HIDE)


$List1= GUICtrlCreateListView("list1", 192, 72, 470, 260, $LVS_SINGLESEL, $LVS_EX_GRIDLINES + $LVS_EX_FULLROWSELECT) ;Exp / Budget
;GUICtrlSetState($List1, $GUI_enABLE)
GUICtrlSetState($List1, $GUI_show)

$Button1 = GUICtrlCreateButton("Button1/list1", 10, 140, 158, 33)
GUICtrlSetState($Button1, $GUI_enABLE)
GUICtrlSetState($Button1, $GUI_FOCUS)
GUICtrlSetFont(-1, 8.5, 800, 0, "Verdana")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xE3E3E3)

$Button2 = GUICtrlCreateButton("Button2/list2", 10, 180, 158, 33)
GUICtrlSetState($Button2, $GUI_enABLE)
GUICtrlSetFont(-1, 8.5, 800, 0, "Verdana")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xE3E3E3)

$cEnterPressed = GUICtrlCreateDummy()

GUISetState(@SW_SHOW)



While 1

    $iMsg = GUIGetMsg()

    Switch $iMsg


        Case $GUI_EVENT_CLOSE

            Exit


        Case $Button1

            If BitAND(GUICtrlGetState($List1), $GUI_enable) Then
                GUICtrlSetBkColor($Button1, $color_white)
                GUICtrlSetBkColor($Button2, 0xE3E3E3)
                GUICtrlSetState($List2, $GUI_hide)
                GUICtrlSetState($List2, $GUI_disABLE)
                GUICtrlSetState($List1, $GUI_show)
            EndIf

        Case $Button2
            If BitAND(GUICtrlGetState($List2), $GUI_enable) Then
                GUICtrlSetBkColor($Button2, $color_white)
                GUICtrlSetBkColor($Button1, 0xE3E3E3)
                GUICtrlSetState($List1, $GUI_hide)
                GUICtrlSetState($List1, $GUI_disABLE)
                GUICtrlSetState($List2, $GUI_show)
            EndIf




EndSwitch

WEnd

I thought I understood using BIT, but at this point I am thinking not.  Therefore I am not sure really how to do this.

Any guidance would be appreciated.  And thanks in advance.

Hobbyist

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