Jump to content
Sign in to follow this  
ako673de

GUICtrlSetBkColor on a button causes TAB to fail with input controls

Recommended Posts

ako673de

Make a GUI with at least two input controls and one button. Set OnEventMode to 1 and create event-handler functions for the input controls. Then set the background colour of the button (doesn't matter which), and then try to press the "TAB" key to switch between the inputs. You will notice, that the first time you press TAB does not generate a "change" event on any input field, but all later TABs continue to work normally. Notice that only TAB is missed once after setting a button's background colour, hitting return or klicking in another control always works as expected (does not miss any "change" event).

In my opinion this is a bug. However by some reason I'm not allowed to post in the bug forum...

AKo

Share this post


Link to post
Share on other sites
ako673de

Code please. I would like to test what you are trying to do.

OK, no problem. In the code attached I have reduced my script to the essential parts. The most important line is marked with a capital letter comment.

After starting the script do the following to see the effect most clearly:

- enter an alphanumeric string in one of the input fields

- leave this field with TAB

- notice the update (stringformat() inside the event handler) to a two digit number

- press the "create" button

- again enter an alphanumeric string in one of the input fields

- again leave it with TAB

- notice that no update will take place (the "change" event obviously does not occur!)

- continue entering anything in any field and notice that from now on the update always works properly...

... but only until next "create", because then another "SetBKColor" is being executed.

The strange thing is, that the very first time everything is fine. The bad behaviour only occurs, if after a "SetBkColor" (and only on a button!) another GUI (or as in my sample script: the same GUI) is been drawn.

#include <GUIConstants.au3>
#Include <Array.au3>
Opt("TrayAutoPause"     ,0)
Opt("GUIOnEventMode"    ,1)

Global $GUI,$Chan,$DStart,$TStart,$Create,$BtnPath

$num=2
$oldnum=1

while 1
    If Not ($num=$oldnum) Then 
        showGUI($num)
        $oldnum=$num
    EndIf
    Sleep(500)
WEnd

Func showGUI($num)
    $GUI            =   GUICreate("DVB Recording Scheduler",731,226,-1,-1,$WS_SYSMENU)
                        GUISetOnEvent($GUI_EVENT_CLOSE,"GUI_Event_Cancel")
    Dim $Chan[$num],$DStart[$num],$TStart[$num]
    For $i=0 To $num-1
                        GUICtrlCreateGroup("",10,20+30*$i,705,35)
        $DStart[$i] =   GUICtrlCreateInput("",310,30+30*$i,60,21,$ES_CENTER)
                        GUICtrlSetOnEvent(-1,"GUI_Event_Dstart")
        $TStart[$i] =   GUICtrlCreateInput("",370,30+30*$i,35,21,$ES_CENTER)
                        GUICtrlSetOnEvent(-1,"GUI_Event_Tstart")
                        GUICtrlCreateGroup("",-99,-99,1,1)
    Next
                        GUICtrlCreateGroup("",                  10,20+30*$num,705,35)
    $Create         =   GUICtrlCreateButton("Create",           655,30+30*$num,50,21)
                        GUICtrlSetOnEvent(-1,"GUI_Event_Create")
                        GUICtrlSetState(-1,$GUI_FOCUS+$GUI_DEFBUTTON)
                        GUICtrlCreateGroup("",-99,-99,1,1)

    GUICtrlSetBkColor($Create,0xff0000) ; LEAVE THIS LINE OUT => WORKS!!!
    GUISetState(@SW_SHOW)
EndFunc
Func GUI_Event_Dstart()
    $entry=_ArraySearch($DStart,@GUI_CtrlId,0,0,0,0)
    GUICtrlSetData($DStart[$entry],StringFormat("%02d",GUICtrlRead($DStart[$entry])))
EndFunc
Func GUI_Event_Tstart()
    $entry=_ArraySearch($TStart,@GUI_CtrlId,0,0,0,0)
    GUICtrlSetData($TStart[$entry],StringFormat("%02d",GUICtrlRead($TStart[$entry])))
EndFunc
Func GUI_Event_Create()
    $num+=1
EndFunc
Func GUI_Event_Cancel()
    Exit
EndFunc

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  

×