How to avoid window flickering

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
I am overdrawing the window title-bar and the border but window title bar flickers while resize of window.<br/>
Is there is any solution to avoid flickering ?
<br/>
public void DrawBorder(ref Message message, int width, int height)<br/>
{<br/>
if (message.Msg == WM_NCPAINT || message.Msg == WM_ERASEBKGND || message.Msg == WM_PAINT)<br/>
{<br/>
IntPtr hdc = GetDCEx(message.HWnd, (IntPtr)1, 1 | 0x0020); if (hdc != IntPtr.Zero)<br/>
{<br/>
Graphics graphics = Graphics.FromHdc(hdc);<br/>
Rectangle rectangle = new Rectangle(0, 0, width, 30);<br/>
Rectangle rectangle1 = new Rectangle(0, 0, width, height);<br/>
SolidBrush blueBrush = new SolidBrush(Color.Green);<br/>
graphics.FillRectangle(blueBrush, rectangle);<br/>
ControlPaint.DrawBorder(graphics, rectangle, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor,
borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid);<br/>
ControlPaint.DrawBorder(graphics, rectangle1, borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid,
borderColor, borderWidth, ButtonBorderStyle.Solid, borderColor, borderWidth, ButtonBorderStyle.Solid);<br/>

<br/>
message.Result = (IntPtr)1;<br/>
ReleaseDC(message.HWnd, hdc);<br/>
}<br/>
}<br/>
}<br/>
Thanks <br/>
SGRao

View the full article
 
Back
Top