473,409 Members | 1,979 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,409 software developers and data experts.

Form Canvas

Is Below the approiate way to clear a Canvas of a windows canvas
or is there a better way, what im doing is painting pictures of
different sizes based on user selection on size
Graphics g = CreateGraphics();
g.FillRectangle(new SolidBrush(Color.White), this.ClientRectangle);

//draw text over each picture
//draw picture loop here
thanks DaveL
Oct 24 '08 #1
3 5412
"DaveL" <dv*****@sbcglobal.netwrote in message
news:_4*****************@nlpi068.nbdc.sbc.com...
Is Below the approiate way to clear a Canvas of a windows canvas
or is there a better way, what im doing is painting pictures of
different sizes based on user selection on size
Graphics g = CreateGraphics();
g.FillRectangle(new SolidBrush(Color.White), this.ClientRectangle);
Without looking at the help files (so I might be wrong), I seem to recall
there is a Graphics.Clear() method.
Oct 24 '08 #2
On Fri, 24 Oct 2008 09:54:49 -0700, DaveL <dv*****@sbcglobal.netwrote:
Is Below the approiate way to clear a Canvas of a windows canvas
or is there a better way, what im doing is painting pictures of
different sizes based on user selection on size
Graphics g = CreateGraphics();
g.FillRectangle(new SolidBrush(Color.White), this.ClientRectangle);

//draw text over each picture
//draw picture loop here
Jeff is correct, there is a Graphics.Clear() method. You don't even need
to create a brush to use it.

However, you shouldn't need to call CreateGraphics() to draw anything.
The only place you ought to be drawing is in the OnPaint() method (or
possibly an event handler for the Paint event, depending on your
implementation), and there a Graphics instance is passed to you in the
PaintEventArgs class.

So if that code is actually similar to what you're using in your program,
you've got a broader design mistake there.

Pete
Oct 24 '08 #3
Thank you, i'll make the changes

DaveL

"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Fri, 24 Oct 2008 09:54:49 -0700, DaveL <dv*****@sbcglobal.netwrote:
>Is Below the approiate way to clear a Canvas of a windows canvas
or is there a better way, what im doing is painting pictures of
different sizes based on user selection on size
Graphics g = CreateGraphics();
g.FillRectangle(new SolidBrush(Color.White), this.ClientRectangle);

//draw text over each picture
//draw picture loop here

Jeff is correct, there is a Graphics.Clear() method. You don't even need
to create a brush to use it.

However, you shouldn't need to call CreateGraphics() to draw anything.
The only place you ought to be drawing is in the OnPaint() method (or
possibly an event handler for the Paint event, depending on your
implementation), and there a Graphics instance is passed to you in the
PaintEventArgs class.

So if that code is actually similar to what you're using in your program,
you've got a broader design mistake there.

Pete

Oct 24 '08 #4

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

Similar topics

6
by: Joseph | last post by:
hi 1) i plan on having an awt canvas component (to draw graphs) on a JFrame with other swing components..will this be okay? i've read that swing and awt aren't compatible.. 2)Also, if i...
0
by: Mickel Grönroos | last post by:
Hi, I'm trying to put an Tkinter.Entry of fixed size onto a specific location on a canvas using the place manager. The idea is that one can double-click a rectangle object on a canvas to get an...
1
by: Mickel Grönroos | last post by:
Hi, I have a Tkinter.Canvas of variable width. Is there a standard way of asking the canvas which parts of it that is visible? I.e. on the horizontal scale, I would like to know at what fraction...
5
by: Andrew Poulos | last post by:
Is there a right/best way to draw an ellipse using Canvas? (With VML there's the v:oval element which makes the exercise trivial). I tried drawing a 360 degree arc (a circle) and then scaling it...
11
by: Aaron Gray | last post by:
Hi, I have put together a bit of JavaScript to make a square resizable canvas :- http://www.aarongray.org/Test/JavaScript/resizable.html Problems I have :- a) I cannot seem to center it...
2
TMS
by: TMS | last post by:
Schools over!!! Now its time to play. I would like to learn how to make objects move from one location to the next on a canvas widget. For example: from Tkinter import * class square:...
2
by: devnew | last post by:
hi i am new to tkinter and would like some help with canvas i am doing validation of contents of a folder and need to show the ok/error messages on a canvas resultdisplay =Canvas(...)...
10
by: blaine | last post by:
Hey everyone! I'm not very good with Tk, and I am using a very simple canvas to draw some pictures (this relates to that nokia screen emulator I had a post about a few days ago). Anyway, all is...
4
by: moondaddy | last post by:
I have a wpf project where I use a canvas to drag shapes around. when I drag a shape beyond the right or bottom side I get scrollbars which is good. I also get scrollbars when I zoom in and a...
4
by: =?GB2312?B?0rvK18qr?= | last post by:
Hi all, Today I was writing a simple test app for a video decoder library. I use python to parse video files and input data to the library. I got a problem here, I need a windows form, and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.