PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework e.Graphics.DrawImage don't redraws

Reply

e.Graphics.DrawImage don't redraws

 
Thread Tools Rate Thread
Old 13-09-2006, 04:03 PM   #1
Bram Hoefnagel
Guest
 
Posts: n/a
Default e.Graphics.DrawImage don't redraws


I'm develloping a c# wm5.0 app. and run into some graphics problem,
which I can't figure out. Hopefully somebody can help me.

I draw an image on a tabpage, this image contains several ellipses on
different locations.
However there's also a combox in the tabpage, which takes care of the
selection of ellipses on the tabpage.

The problem is that the first drawing of ellipses if done well, however
after another selection there must be ellipses drawn on different
locations. This doesn't work. The old ellipses are still in place and
no new ones are drawn.

private Image _image;
private Graphics _graphics;

In the constructor I load the background image where the ellipses must
be placed on:
_image = new System.Drawing.Bitmap(PDAback.gif");

after the (combobox) selection:
_graphics = Graphics.FromImage(_image);
foreach ellipse:
_graphics.FillEllipse(new SolidBrush(Color.Red), xPosPix, yPosPix, 10,
10);

and finally the overrided paint:
private void tabPageOverzicht_Paint(object sender, PaintEventArgs e)
{
// Draw image to screen.
e.Graphics.DrawImage(_image, 0, 0);
// Dispose of graphics object.
if (_graphics != null)
_graphics.Dispose();
}

So the problem is that the _graphics.FillEllipse() method the second
time, fills new (different) ellipses, but the old ones are still shown,
and the new ones not.

Thnx

  Reply With Quote
Old 16-09-2006, 07:46 PM   #2
Simon Hart
Guest
 
Posts: n/a
Default Re: e.Graphics.DrawImage don't redraws

A selection of the combobox item I believe does not cause a WM_PAINT message
to be
generated, so you will explicitly need to call the Refresh() method after
the combo selection.

Regards
Simon.

"Bram Hoefnagel" <bhoefnagel@actemium.nl> wrote in message
news:1158159799.591995.323790@e3g2000cwe.googlegroups.com...
> I'm develloping a c# wm5.0 app. and run into some graphics problem,
> which I can't figure out. Hopefully somebody can help me.
>
> I draw an image on a tabpage, this image contains several ellipses on
> different locations.
> However there's also a combox in the tabpage, which takes care of the
> selection of ellipses on the tabpage.
>
> The problem is that the first drawing of ellipses if done well, however
> after another selection there must be ellipses drawn on different
> locations. This doesn't work. The old ellipses are still in place and
> no new ones are drawn.
>
> private Image _image;
> private Graphics _graphics;
>
> In the constructor I load the background image where the ellipses must
> be placed on:
> _image = new System.Drawing.Bitmap(PDAback.gif");
>
> after the (combobox) selection:
> _graphics = Graphics.FromImage(_image);
> foreach ellipse:
> _graphics.FillEllipse(new SolidBrush(Color.Red), xPosPix, yPosPix, 10,
> 10);
>
> and finally the overrided paint:
> private void tabPageOverzicht_Paint(object sender, PaintEventArgs e)
> {
> // Draw image to screen.
> e.Graphics.DrawImage(_image, 0, 0);
> // Dispose of graphics object.
> if (_graphics != null)
> _graphics.Dispose();
> }
>
> So the problem is that the _graphics.FillEllipse() method the second
> time, fills new (different) ellipses, but the old ones are still shown,
> and the new ones not.
>
> Thnx
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off