[Mono-winforms-list] Dynamic drawing of Images on the form

Rolf Bjarne Kvinge rolflists at ya.com
Wed Sep 12 10:05:56 EDT 2007




>B. you can code up the OnPaint function to paint the correct ONE of your
images.  Then you can make a Timer object on your form.  When the timer
fires, you can call the static Graphics.FromHwnd to get a graphics object
and directly >paint the newer image.  Also update a member variable with the
current image so that if your window is covered and uncovered it will paint
the correct thing.

Instead of directly drawing the image, in this case use Invalidate
(ImageRectangle) which will cause OnPaint to be called, thereby avoiding

From: mono-winforms-list-bounces at lists.ximian.com
[mailto:mono-winforms-list-bounces at lists.ximian.com] On Behalf Of Abir
Sent: Wednesday, September 12, 2007 6:16 AM
To: mono-winforms-list at lists.ximian.com
Subject: [Mono-winforms-list] Dynamic drawing of Images on the form

I need to display some dynamic images on a windows form at regular intervals
based on some logic. The code runs perfectly fine with .NET and as well as
the Win MONO(1.2.4) platforms , but when I port the identical code to the
Mono develop running on the Linux (2.6.22-Fedora) the images are displayed
in sporadic bursts . 

The code snippet:
protected override void OnPaint(PaintEventArgs e)
            Graphics gr ,gf;
            gr = e.Graphics;
            gf = Graphics.FromHwnd(this.Handle);

            for (; intCtr < Cntr; intCtr += 1)

                // call the final rect
                //passEncStr = enS.EnCodeString((string)a2[intCtr]);
                gf.FillRectangle(new SolidBrush(this.BackColor),

                if (intCtr == Cntr - 1)
                    intCtr = 0;




I s there a problem with the primary thread Sleep methods ?

-- Visit us at http://www.2pirad.com/ --

More information about the Mono-winforms-list mailing list