Sign in to follow this  
Followers 0
darkxraver

gui checkbox, <= value and GUICtrlSetBkColor

4 posts in this topic

#1 ·  Posted (edited)

once again i have a problem.. i tried and tried and searched but cant manage to find a solution..

heres a part of my script

$earth1 = GUICtrlCreateInput($e1ini, 45, 70, 55, 20,$ES_READONLY)

$low = GUICtrlCreateCheckbox("Highlight Low Elements", 5, 366)

Case BitAND(GUICtrlRead($low), $GUI_CHECKED)
            Switch GUICtrlRead($earth1)
                Case 0 to 1999
                GUICtrlSetBkColor($earth1, 0xff0000)
        EndSwitch
            
        Case BitAND(GUICtrlRead($low), $GUI_UNCHECKED)
            GUICtrlSetBkColor($earth1, 0xEBE9ED)
        EndSelect

it should do the exact same thing like this code but for some reason the GUICtrlCreateInput which is $earth1 is flimmering/flickering or glimmers or what you wanna call it.. is there another solution so that it wont flimmer/flicker/glimmer?

if the value of $earth1 is from <= 1999 (0-1999) and the checkbox $low is checked it should change the background of the GUICtrlCreateInput to red

if the value of $earth1 is from >= 2000 and the checkbox $low is checked or the checkbox $low is unchecked it should change the background of the GUICtrlCreateInput to the standart color which is grey

any way to do this?

thx

Edited by darkxraver

Share this post


Link to post
Share on other sites



darkxraver,

It is a common problem - you are setting the backcolour on every loop, even if there is no change, which causes the flicker. The solution is to use a flag to check for a change in state and only then change the backcolour:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

GUICreate("Test", 200, 200)

$earth1 = GUICtrlCreateInput("", 45, 70, 55, 20,$ES_READONLY)

$low = GUICtrlCreateCheckbox("Highlight Low Elements", 25, 166)

; $fLow_Checked is boolean and matches the state of checkbox:  1 = checked, 0 = unchecked
$fLow_Checked = 0

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        
    EndSwitch

    If BitAND(GUICtrlRead($low), $GUI_CHECKED) <> $fLow_Checked Then
        
        $fLow_Checked = Not $fLow_Checked
; make the state boolean match the checkbox

        If $fLow_Checked Then
            Switch GUICtrlRead($earth1)
                Case 0 to 1999
                GUICtrlSetBkColor($earth1, 0xff0000)
            EndSwitch
        Else        
            GUICtrlSetBkColor($earth1, 0xEBE9ED)
        EndIf
    EndIf


WEnd

It means a bit more coding, but a much nicer GUI at the end.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

oh ic x-x

its simple if you know how x:

thanks a bunch

i have to give credits to you guys since you help me out alot :)

Edit: and the thing is i never scripted something that "big" only a few lines.. and here i am already at 648 lines :) and im already starting to lose track cause of so many lines

Edited by darkxraver

Share this post


Link to post
Share on other sites

darkxraver,

I presume you are using SciTE. Try using the #Region....#EndRegion directives. They allow you to "shrink" parts of your code that you are not working on.

look at this:

#Region

; Now you see me!

#EndRegion
#Region - Title 2

; I am visible!

#EndRegion

Just click on the little [-] boxes that appear in SciTE next to the #Region lines. Or you can use "View - Toggle all folds" from the menu. Do not forget to put a suitable title after #Region, or you will not know what is hidden where!

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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