c# - Flickering issue when overriding WM_PAINT in windows forms -



c# - Flickering issue when overriding WM_PAINT in windows forms -

i guess generic issue , not limited combobox, have problem combobox. extended combobox object mycb mycb : combobox)

what happens every time hover on control, leave control, expand selection box or select value, command flickers. short while can see default (non-replaced) command beingness instantly replaced mine.

i believe what's happening windows first draws "original" command (by calling base.wndproc()) , repaints mine.

the question is, can somehow stop windows painting it's own command , instantly paint mine?

below code overriding wndproc

protected override void wndproc(ref message m) { base.wndproc(ref m); if (m.msg == wm_paint) { graphics gg = this.creategraphics(); gg.fillrectangle(borderbrush, this.clientrectangle); // ... // //draw arrow gg.fillpath(arrowbrush, pth); // ... // if(this.text == "") gg.drawstring("-- select --", this.font, new solidbrush(color.black), rf, sf); else gg.drawstring(this.text, this.font, new solidbrush(color.black), rf, sf); gg.dispose(); } }

what have tried far:

i know can't this:

if (m.msg == wm_paint) { ... } else { base.wndproc(ref m); }

as cause command repaint infinitely (not sure why)

i able remove flickering happened when mouse leaves/enters command adding code

if (m.msg == wm_mousefirst || m.msg == wm_mouseleave) // 0x0200 0x02a3 { m.result = (intptr)1; } else { base.wndproc(ref m); if (m.msg == wm_paint) { ... } }

however doesn't solve problem completely

i looked ilspy check on combobox's wndproc there many windows messages didn't know of perchance immitate achive goal

c# combobox custom-controls

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -