Jump to content

Combo problem using CBS_DROPDOWNLIST (artefacts)


Go to solution Solved by cyberyeye,

Recommended Posts

Posted

Hi there !

I'm using Windows 24h2 (dark mode) using latest AutoIT stable version (v3.3.18.0)

Here's a minimal GUI done quickly using Koda to demonstrate the rendering problem when using any combobox with style $CBS_DROPDOWNLIST. The combo appears visually corrupted as shown on the two screen capture : is there another recommended style or know workaround to fix this and having combobox "read‑only" without these visual rendering problem ?

 

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Gui = GUICreate("Form1", 615, 143, 192, 124)
$Combo1 = GUICtrlCreateCombo("", 247, 16, 145, 25, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "Item 1|Item 2|Item 3")
$Label1 = GUICtrlCreateLabel("Gui Test using Koda", 16, 16, 100, 17)
$Button1 = GUICtrlCreateButton("Exit", 263, 80, 89, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE,$Button1
            GUIDelete($Gui)
            Exit

    EndSwitch
WEnd

 

Capture-1.PNG

Capture-2.PNG

  • Solution
Posted

Finally I found a kind of "workaround" from an old script wrote near 10 years ago 😄
adding

DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Combo1), "wstr", 0, "wstr", 0)

to set/force a classic style to the combo = fix this visual glitches for combo when using  $CBS_DROPDOWNLIST
 

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Gui = GUICreate("Form1", 615, 143)
$Combo1 = GUICtrlCreateCombo("Item 1", 247, 16, 145, 25, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "Item 1|Item 2|Item 3")
; apply classic style to combo <= the fix
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Combo1), "wstr", 0, "wstr", 0)
$Label1 = GUICtrlCreateLabel("Gui Test using Koda", 16, 16, 100, 17)
$Button1 = GUICtrlCreateButton("Exit", 263, 80, 89, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE,$Button1
            GUIDelete($Gui)
            Exit

    EndSwitch
WEnd

Clearly this is *not* a real solution but at least this "workaround" fixed my problem 👍

Maybe @Jos could check if there is a problem introduce by Windows 11 when using : GUICtrlCreateCombo + $CBS_DROPDOWNLIST ? Probably another Miscrosoft insanity.

Capture-1.PNG

Capture-2.PNG

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
×
×
  • Create New...