[Mono-winforms-list] Control Painting
Peter Dennis Bartok
peter@novonyx.com
Tue, 15 Mar 2005 21:41:25 -0700
If the override of OnPaint is done by MS, it should be considered the
'proper' method. I know there's some drawing done via WM_PAINT today, but
it's against the rules and will get changed once we have some cycles to
review controls. If MS does not document that their control overrides
OnPaint, the control should register for the Paint event instead (Paint +=
new PaintEventHandler...)
Cheers,
Peter
-----Original Message-----
From: "Jonathan S. Chambers" <Jonathan.Chambers@ansys.com>
To: <mono-winforms-list@lists.ximian.com>
Date: 15 March, 2005 21:20
Subject: [Mono-winforms-list] Control Painting
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 = 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
_______________________________________________
Mono-winforms-list maillist - Mono-winforms-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-winforms-list