[Mono-winforms-list] Control Painting

Jonathan S. Chambers Jonathan.Chambers@ansys.com
Thu, 24 Mar 2005 23:00:28 -0500

     I am responding to the user dragging the divider in the property =
grid to resize the two columns. In the OnMouseMove event, if the user is =
resizing the columns, I draw and then call Refresh(). Supposedly this =
should cause an immediate repaint (and the code in Control.Refresh() =
appears to do this). However, I get many more MouseMove events fired =
before the actual repaint happens (causing more draws and Refresh =
calls). This causes the dragging to appear very jagged. Is this correct =
behavior, I mean should I be able to receive many MouseMoveEvents before =
OnPaint is actually called  due to my call to Refresh?

Thanks Again,

-----Original Message-----
From:	mono-winforms-list-admin@lists.ximian.com on behalf of Jonathan S. =
Sent:	Thu 3/24/2005 10:31 PM
To:	Mono-winforms-list@lists.ximian.com
Subject:	[Mono-winforms-list] Control Painting
In Control.cs in the WndProc method, the handling of the paint event is =
as follows:

case Msg.WM_PAINT: {			=09
	PaintEventArgs	paint_event;

	paint_event =3D XplatUI.PaintEventStart(Handle);

	if ((control_style & (ControlStyles.AllPaintingInWmPaint | =
ControlStyles.UserPaint)) =3D=3D (ControlStyles.AllPaintingInWmPaint | =
ControlStyles.UserPaint)) {

	if (!GetStyle(ControlStyles.UserPaint)) {
		DefWndProc(ref m);

If I read ths correctly, OnPaintBackground will be called if the =
control_style includes ControlStyles.AllPaintingInWmPaint and =
     I believe this should be the opposite (change =3D=3D to !=3D). If =
ControlStyles.AllPaintingInWmPaint and ControlStyles.UserPaint are set =
(i.e. everything is done in OnPaint), OnPaintBackground should not be =
     I have tried to change my drawing code from using the WndProc to =
overriding OnPaint. This change helps a bit (I don't see the background =
color flash), but my drawing seems much slower (almost as if double =
buffering is not working with this method???).

- Jonathan
Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com