Sign in to follow this  
Followers 0
jchapman15

Input field retains BG color after being disabled

2 posts in this topic

Sorry if the answer to this is apparent somewhere, I looked up and down but could not figure this out.

If you have an input field and color it using GUICtrlSetBkColor then disable it later it retains the BG color instead of being set to gray.

Do you have to manually control the color after setting it or is there a way to remove the color and reset the field to it's default setting of white when enabled and gray when disabled?

this computer uses IE6 which won't let me post code (or much else) properly but here's the snippet:

#include <GUIConstantsEx.au3>
$guiMain = GUICreate("Enter Information", 200, 150)
$txtInput = GUICtrlCreateInput("", 25, 25, 150)
$btnSave  = GUICtrlCreateButton("Save", 25, 55)
$btnEnable  = GUICtrlCreateButton("Enable Field", 100, 55)
$btnDisable = GUICtrlCreateButton("Disable Field", 100, 85)

GUISetState(@SW_SHOW)
While 1
 $msg = GUIGetMsg()
 Select
  Case $msg = $GUI_EVENT_CLOSE
   Exit
  Case $msg = $btnSave
   If GUICtrlRead($txtInput) = "" Then
    GUICtrlSetBkColor($txtInput, "0xff0000")
   EndIf
  Case $msg = $txtInput
   ;would reset field to default state here
   GUICtrlSetBkColor($txtInput, "0xffffff")
  Case $msg = $btnEnable
   GUICtrlSetState($txtInput, $GUI_ENABLE)
  Case $msg = $btnDisable
   GUICtrlSetData($txtInput, "")
   GUICtrlSetState($txtInput, $GUI_DISABLE)
 EndSelect
Wend

Share this post


Link to post
Share on other sites



I thought there might be an easier way, but thanks!

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