Digging for undocumented system calls
Posted by noah on October 9, 2008
After much reverse engineering and stepping through MS source code looking for how the .net framework renders the simple black X close button for maximized MDI windows, I’ve found something which is well documented. DrawCaptionButton. Sigh. Well, here it is in case I forget.
Image ControlImage;
protected override void OnPaint(PaintEventArgs pe)
{
pe.Graphics.Clear(BackColor);
pe.Graphics.DrawImage(ControlImage, 0 , 0);
}
Image GetImage()
{
Bitmap image = new Bitmap(0x10, 0x10);
using (Graphics graphics = Graphics.FromImage(image))
{
ControlPaint.DrawCaptionButton(graphics, new Rectangle(Point.Empty, image.Size), CaptionButton.Close, ButtonState.Flat);
graphics.DrawRectangle(SystemPens.Control, 0, 0, image.Width - 1, image.Height - 1);
}
image.MakeTransparent(SystemColors.Control);
return image;
}