Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2005

Tip: Looking for answers? Try searching our database.

Graphics 101. Updating drawing.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob Brooks - 29 Sep 2005 16:14 GMT
Hi,

I'm going some drawing via "Graphics" in a "Paint" callback and the commands
will only manifest themselves if I minimise the window and then maximise it
again.

I'm new to windows programming and so I am obviously missing a lot of the
basics when it comes to this sort of thing but my mandate is to get a
utility up and running ASAP.

What's the magic function call I'm missing?

Many thanks,

R.
private void PictureBox_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)

{

Graphics graphics = e.Graphics;

System.Drawing.Pen pen = new Pen( System.Drawing.Color.White );

graphics.DrawPath( pen, graphicsPath1 );

}
Francisco Garcia Gomez - 29 Sep 2005 16:26 GMT
Rob,

Paint event will only be fired when there's the need to paint something.
That is why you must minimize your window in order to see your code work.

Whenever you want a piece of a control / form to be painted, you should call
Invalidate on that control / form. You can optionally pass the area to
invalidate as an argument to Invalidate.

The Paint event won't be fired immediately; it will be fired when your
application has no other events to process. You can force a control to
repaint itself by calling Refresh, but it is better waiting for the system
to do it automatically.

You can optimize your Paint logic if you look at the Clip rectangle passed
to you. It tells you which part of the control needs being repainted.

Hope it helps

> Hi,
>
[quoted text clipped - 23 lines]
>
> }
Rob Brooks - 29 Sep 2005 17:02 GMT
Cool. Thanks for that.

I was able to Invalidate my PictureBox in the Form by passing just a
Rectangle to the Invalidate member function of the PictureBox.

I seemed to be the best version to use use as I was merely plotting a
control point cursor on the picturebox with a mouse click.

Nice and efficient.

Thanks again.

R.

> Rob,
>
[quoted text clipped - 14 lines]
>
> Hope it helps

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.