Jump to content
Sign in to follow this  
Andreik

GUICtrlSetColor behavior

Recommended Posts

Andreik

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

Share this post


Link to post
Share on other sites
FireFox

Hi,

It seems to be related to the Combo control, try with a button and you will see.

I'm looking at it.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Andreik

Indeed but this is quite odd, is this how it should work or is a bad behavior?


When the words fail... music speaks

Share this post


Link to post
Share on other sites
FireFox

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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.