[Mono-winforms-list] Control Painting

Jonathan S. Chambers Jonathan.Chambers@ansys.com
Tue, 15 Mar 2005 23:19:41 -0500


    Most controls seem to be painted by overriding the WndProc method =
and doing something as follows:

protected override void WndProc (ref Message m)
{
	switch ((Msg) m.Msg) {
	case Msg.WM_PAINT:
		PaintEventArgs	paint_event;
		paint_event =3D XplatUI.PaintEventStart (Handle);
		PaintInternal (paint_event);
		XplatUI.PaintEventEnd (Handle);
		break;
	default:
		base.WndProc (ref m);
		break;
	}
}

     This is what I am currently doing in the propertygrid as well. =
However, under the Guidlines for SWF, it says to override the OnPaint =
event and draw the image buffer (which was updated previously I assume):

protected override void OnPaint (PaintEventArgs pevent) {
         pevent.Graphics.DrawImage (this.ImageBuffer,
                                    pevent.ClipRectangle,
                                    pevent.ClipRectangle,
                                    GraphicsUnit.Pixel);
      }

So, which drawing method is correct (or both or neither for that =
matter)?

Thanks,
Jonathan