[Mono-list] Windows.Forms control flicker and wrapper classes.

Bouk, Nathan NBouk at PLANSYS.COM
Fri Dec 1 15:23:30 EST 2006


I tried that. It helps, but its not a complete fix. The
TreeViewWithPaint does two main things. It catches the erase back ground
messages and ignores them, and it forces the control to the draw to a
bitmap, and then draws the bitmap to the screen. BeginUpdate() and
EndUpdate() might cause the control to not do normal paints between
them, but it will still receives and responds to the erase backgrounds,
causing flickering. Maybe BeginUpdate() and EndUpdate() are enough to
solve the problem if you are updating the TreeView only occasionally,
but I'm using it for a constantly updating data display, and they did
not cause the once a second update flickering to stop by themselves. I
think the Mono TreeView control is a little smarter than that, so maybe
BeginUpdate() and EndUpdate() solve the entire problem when running
under Mono.

 

It's more an issue of managing compiling and changing the type name from
TreeView to TreeViewWithPaint depending on the system. Under C/C++ I
could probably use a preprocessor #ifdef _WIN32 to deal with it, but how
do I deal with that under .NET/Mono?

 

________________________________

From: Alan McGovern [mailto:alan.mcgovern at gmail.com] 
Sent: Friday, December 01, 2006 10:58 AM
To: Bouk, Nathan; mono-list at lists.ximian.com
Subject: Re: [Mono-list] Windows.Forms control flicker and wrapper
classes.

 

Why not just use TreeView.BeginUpdate() to disable repainting, and after
you've finished updating the treeview call treeView.EndUpdate() which
will reenable repainting. That will stop the flickering.

Alan.

On 11/30/06, Bouk, Nathan <NBouk at plansys.com> wrote:

I've been developing a Windows.Forms app, and I've been trying to
maintain compatibility with Mono at the same as MS .NET. I recently
tried using the Windows.Forms.Treeview control, and found that it
sucked. The underlying native control was fine, but the Windows.Forms
wrapper was so poorly written it caused it to flicker like it was going
out of style (and it is!). To fix this I started using a wrapper class
around Windows.Forms.Treeview that inherits from Treeview, but hijacks
the WndProc() function, and in order to enforce strict double buffering,
it had to call a few Win32 functions that aren't nicely wrapped in .Net
(GetUpdateRect, BeginPaint, and EndPaint) which were used with PInvoke.
The class can be found on codeproject at
http://www.codeproject.com/cs/miscctrl/genmissingpaintevent.asp , and it
solves the flickering problem nicely, but now my project has a huge
Win32 dependency. 

 

Does anyone have any ideas how I can maintain one project that can use
this TreeViewWithPaint class in Microsoft .NET, but use the Mono
Windows.Forms.Treeview when running on Mono?


_______________________________________________
Mono-list maillist  -  Mono-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list



 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20061201/bb07c309/attachment-0001.html 


More information about the Mono-list mailing list