Skip to content

Custom WinForms ComboBox Flickers in Windows 11 #13325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jmiles17 opened this issue Apr 18, 2025 · 1 comment
Open

Custom WinForms ComboBox Flickers in Windows 11 #13325

jmiles17 opened this issue Apr 18, 2025 · 1 comment

Comments

@jmiles17
Copy link

I work on a Visual Studio extension.
I have been testing the extension on version 17.13 of Visual Studio with .NET Framework version 4.8

I have a custom WinForms ComboBox which I repaint by intercepting WM_PAINT in WndProc.
I first call base.WndProc.
Then I paint the background, border and dropdown button, and when the ComboBox is not editable, I also paint the text.

I also handle OnMouseEnter and OnMouseLeave, but I merely set a private '_isHovered' variable and then call the base function, and I do not call Invalidate()

I am also intercepting wm_ctlcoloredit and wm_ctlcolorstatic, but those do not seem related to this.

On Windows 10, the control works reasonably well and there is no flickering.
On Windows 11, when I hover over the control, it flickers a fair amount, especially when I hover back and forth near the dropdown button.

I have tried the following:
- Intercept wm_erasebkgnd
○ This seems to help a little, but not much.
- Set UserPaint, OptimizedDoubleBuffer, AllPaintingInWmPaint
○ This did not seem to help, and I also seem unable/do not know how to render the text correctly for an editable ComboBox
- Override CreateParams and set ws_ex_composited
○ I did this in the custom ComboBox itself, not the form, because it is just the specific hovered control that is flickering
○ This causes an unknown error

I have tried some other small changes too.

Do you have any advice/know what might be causing this issue?

Also, I see this issue: #12739
but it does not seem entirely relevant.

Thanks.

@Tanya-Solyanik Tanya-Solyanik added external-OS-issue Issue caused by an external OS component such as Common Controls. and removed external-OS-issue Issue caused by an external OS component such as Common Controls. labels Apr 21, 2025
@jmiles17
Copy link
Author

jmiles17 commented Apr 22, 2025

I posted a sample application with the combobox here:
https://github.com/jmiles17/winforms_combobox_sample

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants