#3854 closed Bug

Setting Control Color has unintended consequences in GUI — at Version 4

Reported by: paul.keselman@… Owned by:
Milestone: Component: AutoIt
Version: 3.3.14.5 Severity: None
Keywords: Cc:

Description (last modified by mLipok)

Uncommenting GUICtrlSetColor creates a bug where interacting with the input, also causes the button function to be executed

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 200, 100)
$hButton = GUICtrlCreateButton("Button", 10, 10, 160, 24)
;GUICtrlSetColor($hButton, 0xFF0000)
$hInput = GUICtrlCreateInput("", 10, 40, 60, 24)
GUISetState()

While 1
   Switch GUIGetMsg()
          Case $hButton
                 ConsoleWrite("Button" & @CR)
          Case $hInput
                 ConsoleWrite("Input" & @CR)
          Case $GUI_EVENT_CLOSE
                 Exit
   EndSwitch
WEnd

Change History (4)

comment:1 by paul.keselman@…, on Nov 15, 2021 at 7:19:43 PM

There is a bug in my code. Please change
GUICtrlSetColor($hConnectionButton, 0xFF0000)
to
GUICtrlSetColor($hButton, 0xFF0000)

comment:2 by Jos, on Nov 16, 2021 at 6:50:26 PM

Description: modified (diff)

I updated the code in the original post but don't understand what your issues is you are trying to report here. I have the impression the code works the same with or without that line?
Or do you mean when you type something in the input field and hit enter after which both events fire?

comment:3 by Jos, on Nov 16, 2021 at 6:55:49 PM

It seems that the GUICTRLSetColor() also sets the focus to the button.
This works fine:

#include <GUIConstantsEx.au3>
$hGUI = GUICreate("Test", 200, 100)
$hButton = GUICtrlCreateButton("Button", 10, 10, 160, 24)
GUICtrlSetColor($hButton, 0xFF0000)
$hInput = GUICtrlCreateInput("", 10, 40, 60, 24)
GUICtrlSetState($hInput, $GUI_FOCUS)
GUISetState()
While 1
	Switch GUIGetMsg()
		Case $hButton
			ConsoleWrite("Button" & @CR)
		Case $hInput
			ConsoleWrite("Input" & @CR)
		Case $GUI_EVENT_CLOSE
			Exit
	EndSwitch
WEnd

Not sure whether this is intended or a bug.

comment:4 by mLipok, on Nov 17, 2021 at 3:19:53 PM

Description: modified (diff)
Note: See TracTickets for help on using tickets.