Hi there,
I'm trying to give the button control (System.Windows.Forms.Button) a different appearence. Therefore I overrode the buttons OnPaint method
protected override void OnPaint(PaintEventArgs pe)
{ do some paintings }
The rendering works but the original button partially looks through my painting.
How can I get rid of the original button surface
Can anyone help me
Thanks in advance...

Overriding Button Control
BruceS
Sorry for the doublepost, but my browser won't let me edit my posts.
karch
cool solution!
Thank you for your help.
topdoubledigit
Hi,
You can do two things, the first option overriding the OnPaint, you can do your drawing and do not call the base OnDraw, so no further drawing is executed.
If you want to go a little deeper, just override the
protected override void WndProc(ref Message m)
{
const int WM_PAINT = 0x000F;
switch (m.Msg)
{
case WM_PAINT:
{
RenderFunction();
break;
}
default:
{
base.WndProc (ref m);
break;
}
}
}
Remember to call the base one if you are not using the event, otherwise no message will go through and your app will not response.
Hope this helps.
Regards
Gonzalingui
I didn't call the base method and I overrode the other OnPaint method, but the original button can still be seen. The crucial hint was to call the Clear method. Now everthing works fine!
Thank you very much.
Bastian
You can first clear you Graphics with the Clear method of the Graphics object, if needed.