Jump to content



Photo

[solved] how to change the color of $GUI_DISABLE


  • Please log in to reply
2 replies to this topic

#1 kor

kor

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 499 posts

Posted 01 August 2012 - 08:42 PM

I have some inputs that I am setting the background color to be something other than white.

I've noticed that if I use GuiCtrlSetState($control, $GUI_DISABLE) it does in fact disable the inputs, but it does not "gray out" the input as it would if the background color were default.

Is there a way to either specify the color that $GUI_DISABLE uses to signify a disabled input, or some way I can manually change the color in a second GuiSetBkColor statement?

Func _CreateInput($sText = "", $iLeft = 0, $iTop = 0, $iWidth = 120, $iHeight = 20) Local $oControl = GUICtrlCreateInput($sText, $iLeft, $iTop, $iWidth, $iHeight, BitOR($SS_CENTERIMAGE, $ES_AUTOHSCROLL)) GUICtrlSetBkColor($oControl, 0xE5F5E5) Return $oControl EndFunc ;==>_CreateInput


Func _Control($sState, $c0 = 0, $c1 = 0, $c2 = 0, $c3 = 0, $c4 = 0, $c5 = 0, $c6 = 0, $c7 = 0, $c8 = 0, $c9 = 0) If $sState = "Enable" Then $sState = $GUI_ENABLE + $GUI_SHOW If $sState = "Disable" Then $sState = $GUI_DISABLE + $GUI_SHOW If $c0 <> 0 Then GUICtrlSetState($c0, $sState) If $c1 <> 0 Then GUICtrlSetState($c1, $sState) If $c2 <> 0 Then GUICtrlSetState($c2, $sState) If $c3 <> 0 Then GUICtrlSetState($c3, $sState) If $c4 <> 0 Then GUICtrlSetState($c4, $sState) If $c5 <> 0 Then GUICtrlSetState($c5, $sState) If $c6 <> 0 Then GUICtrlSetState($c6, $sState) If $c7 <> 0 Then GUICtrlSetState($c7, $sState) If $c8 <> 0 Then GUICtrlSetState($c8, $sState) If $c9 <> 0 Then GUICtrlSetState($c9, $sState) EndFunc ;==>_ControlEnable

Edited by kor, 01 August 2012 - 11:35 PM.








#2 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,757 posts

Posted 01 August 2012 - 08:59 PM

kor,

Do you ever try to solve these simple problems yourself before posting :huh:

You actually suggest the very thing you need to do: ;)
AutoIt         
#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20) GUICtrlSetBkColor(-1, 0x00FF00) $cButton = GUICtrlCreateButton("Disable", 10, 50, 80, 30) GUISetState() While 1     Switch GUIGetMsg()         Case $GUI_EVENT_CLOSE             Exit         Case $cButton             If BitAnd(GUICtrlGetState($cInput), $GUI_ENABLE) Then                 GUICtrlSetBkColor($cInput, 0xFF0000)                 GUICtrlSetState($cInput, $GUI_DISABLE)                 GUICtrlSetData($cButton,"Enable")             Else                 GUICtrlSetBkColor($cInput, 0x00FF00)                 GUICtrlSetState($cInput, $GUI_ENABLE)                 GUICtrlSetData($cButton,"Disable")             EndIf     EndSwitch WEnd

All clear? :)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items

#3 kor

kor

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 499 posts

Posted 01 August 2012 - 09:22 PM

Why of course :)
But thank you.
Here is my solution.

Func _Control($sState, $aInput) Local $sColor If $sState = "Enable" Then $sState = $GUI_ENABLE + $GUI_SHOW $sColor = 0xE5F5E5 ElseIf $sState = "Disable" Then $sState = $GUI_DISABLE + $GUI_SHOW $sColor = 0xD6D3CE EndIf For $i = 0 To UBound($aInput) - 1 GUICtrlSetState($aControls[$aInput[$i]], $sState) GUICtrlSetBkColor($aControls[$aInput[$i]], $sColor) GUICtrlSetData($aControls[$aInput[$i]], "") Next EndFunc   ;==>_Control





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users