473,320 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Do I Have to Redraw Graphics?

I am using a Graphics object to draw on a form. If I pop up a message
box, or if say the user minimizes and then restores the form, my
graphics are erased (just where the box was in the former case).

Do I have to detect these things and redraw, or is there a way to
prevent this from happening?
--
To Email Me, ROT13 My Shown Email Address

Nov 21 '05 #1
4 1338
"John Baker" <wb********@wzwfreivprf.pbz> schrieb:
I am using a Graphics object to draw on a form. If I pop up a message box,
or if say the user minimizes and then restores the form, my graphics are
erased (just where the box was in the former case).

Do I have to detect these things and redraw, or is there a way to prevent
this from happening?


Override your form's/control's 'OnPaint' method and perform the drawing
there.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #2
You must repaint by overriding the Form's Paint method.
"John Baker" <wb********@wzwfreivprf.pbz> wrote in message
news:nD***************@fe1.columbus.rr.com...
I am using a Graphics object to draw on a form. If I pop up a message box,
or if say the user minimizes and then restores the form, my graphics are
erased (just where the box was in the former case).

Do I have to detect these things and redraw, or is there a way to prevent
this from happening?
--
To Email Me, ROT13 My Shown Email Address

Nov 21 '05 #3
John,
The Paint event (OnPaint method) is called each time you need to draw,
within the Paint event you want to use e.Graphics to do you drawing rather
then calling CreateGraphics directly. You do not need to displose of the
e.Graphics object, but you should dispose of other System.Drawing objects
that you may create.

The following article discusses the drawing on the form in more detail:

http://www.bobpowell.net/creategraphics.htm

The above FAQ can be entered at:

http://www.bobpowell.net/gdiplus_faq.htm

Hope this helps
Jay

"John Baker" <wb********@wzwfreivprf.pbz> wrote in message
news:nD***************@fe1.columbus.rr.com...
I am using a Graphics object to draw on a form. If I pop up a message box,
or if say the user minimizes and then restores the form, my graphics are
erased (just where the box was in the former case).

Do I have to detect these things and redraw, or is there a way to prevent
this from happening?
--
To Email Me, ROT13 My Shown Email Address

Nov 21 '05 #4

"John Baker" <wb********@wzwfreivprf.pbz> wrote
I am using a Graphics object to draw on a form. If I pop up a message
box, or if say the user minimizes and then restores the form, my
graphics are erased (just where the box was in the former case).

Do I have to detect these things and redraw, or is there a way to
prevent this from happening?

That is the designed behaviour. For one way to keep the graphics
after minimizing, check out this link:

http://groups.google.com/groups?selm...tngp13.phx.gbl
LFS
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Peter | last post by:
I want to draw some lines on a widget. This works ok, but when I want to redraw, the old lines are still there. How do I clear or refresh the widget, so I can draw a new set of lines? Code...
0
by: PHH | last post by:
Help me, please, When I redraw a ListviewItem in Listview (redraw items with icon and text columms). I used SetStyle(ControlStyle.UserPaint, true) function. And I redraw finish and run...
0
by: WHITETIGER | last post by:
Help me, please, When I redraw a ListviewItem in Listview (redraw items with icon and text columms). I used SetStyle(ControlStyle.UserPaint, true) function. And I redraw finish and run...
2
by: ch424 | last post by:
Hi, Does anybody know the fastest way to trigger a DrawingArea redaw in pygtk? At the moment, I'm using a bit of a hack: def redraw(self): self.area.hide() self.area.show() Is there a...
1
by: kiplring | last post by:
I wrote a program which draw a dancer at cornor of desktop. ( I Accessed through hDC) But It has a problem. I remains all trait at the desktop until I invoke any Redraw( Refresh) action - click,...
5
by: CroDude | last post by:
Hi all! I've made a simple control derived from a panel class which draws gradient in a overrided OnPaintBackground event. Well, I know that I need to redraw control when it's resized by...
1
by: shrewdmonkey | last post by:
Hi all, I'm new to this .NET thing and I was wondering if there is any way to make a splitter control redraw its affected controls while it is being dragged as opposed to when the mouse button...
10
by: Nicolas | last post by:
When I resize (Enlarge) the form while the progress bar is running the rectangle drawing is not going to the end of the rectangle? I got a form with one button, one statusbar with three...
3
by: Bob Steuernagel | last post by:
This code is for a simple drawing program that lets the user draw lines, rectangles, and circles in different colors. When the menu is dropped down to change objects, it erases anything drawn...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.