protected Bitmap drawThemeCloseButton(Int32 state)
{
Bitmap output = new Bitmap(closeButton.Width, closeButton.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics fx = Graphics.FromImage(output);
IntPtr hTheme = OpenThemeData (Handle, "Window");
if (hTheme == IntPtr.Zero)
{
fx.Dispose();
return drawLegacyCloseButton (state);
}
Rectangle rClose = new Rectangle(0, 0, closeButton.Width, closeButton.Height);
RECT reClose = rClose;
RECT reClip = reClose; // should fx.VisibleClipBounds be used here?
IntPtr hDC = fx.GetHdc();
DrawThemeBackground (hTheme, hDC, WP_CLOSEBUTTON, state, ref reClose, ref reClip);
fx.ReleaseHdc (hDC);
fx.DrawImage(output,rClose);
CloseThemeData (hTheme);
fx.Dispose();
return output;
}