Jump to content

GUICtrlSetColor behavior


Andreik
 Share

Recommended Posts

Just now I observed the strange behavior of GUICtrlSetColor that seems to delete the edit control and them recreate it. This is how it works GUICtrlSetColor? I have the code below and to see what I mean just select the edit control and then click the combo control. Can someone try to see if I have just me this issue?

#include <WindowsConstants.au3>


GUICreate("Test")
Global $edit = GUICtrlCreateEdit("",5,10,390,100)
GUICtrlCreateCombo("",5,250,390,20,0x03)
GUICtrlSetData(-1,"Yes|No","Yes")
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
GUISetState()

Do
    Sleep(10)
Until GUIGetMsg() = -3

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    $iCtrl = BitAND($wParam, 0x0000FFFF)
    Switch BitShift($wParam, 16)
        Case 0x0100 ; EN_SETFOCUS
            Switch $iCtrl
                Case $edit
                    If GUICtrlRead($iCtrl) = "Test" Then
                        GUICtrlSetData($iCtrl, "")
                        GUICtrlSetColor($iCtrl, 0)
                    EndIf
            EndSwitch
        Case 0x0200 ; EN_KILLFOCUS
            Switch $iCtrl
                Case $edit
                    If Not GUICtrlRead($iCtrl) Then
                        GUICtrlSetColor($iCtrl, 0x606060)
                        GUICtrlSetData($iCtrl,  "Test")
                    EndIf
            EndSwitch
    EndSwitch
    Return "GUI_RUNDEFMSG"
EndFunc
Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

I don't know if it's an issue or not, but I would say it's an issue.

A workaround :

...

        Case 0x0200 ; EN_KILLFOCUS
            Switch $iCtrl
                Case $edit
                    If Not GUICtrlRead($iCtrl) Then
                        GUICtrlSetData($edit,  "Test")
                        AdlibRegister("setcolor", 0)
                    EndIf
            EndSwitch
    EndSwitch
    Return "GUI_RUNDEFMSG"
EndFunc

Func setcolor()
    AdlibUnRegister("setcolor")
    GUICtrlSetColor($edit, 0x606060)
EndFunc

Br, FireFox.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...