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 / Drawing / April 2005

Tip: Looking for answers? Try searching our database.

Creating a graphics class on a timer and on it's own thread

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gv - 29 Apr 2005 17:31 GMT
Hi all,

New to graphics.

I'm sure this is a simple question. I want to create a class that
I can pass in a control or form and it will draw an rectangle on that object
that I pass in to the class.

I know the code is wrong that I'm posting, can someone please help. I think
looking at the below code you
will understand what I want to do. Of course it doesn't work. I would like
to have a class that draws a rectangle and
fill it with some color and have it in a timer that moves it or redraws it
across the object\control. And using it's on thread

thanks for any help

Imports System.Drawing
Public Class DrawCls

   Public Sub Draw(ByVal Cnt As Object)

       Dim g As Graphics
       Dim pen As Pen = New Pen(Color.Green)
       g.DrawLine(pen, 4, 4, 100, 100)

   End Sub

End Class

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
       Dim Dw As DrawCls
       Dw = New DrawCls
       Dw.Draw(Me)

End Sub

gv
Bob Powell [MVP] - 29 Apr 2005 20:14 GMT
You need to be reading the GDI+ FAQ.

Search for "retained mode" on my site.

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

> Hi all,
>
[quoted text clipped - 35 lines]
>
> gv
gv - 29 Apr 2005 21:22 GMT
Thanks

great site!!!!!

I have one question. For example once I draw something in a button click
event..
Before I click and draw again but in a different location how do I get rid
of the previous graphic?

thanks
Gerry

> You need to be reading the GDI+ FAQ.
>
[quoted text clipped - 39 lines]
>>
>> gv

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.