| | |
retaining graphics
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
![]() |
•
•
Join Date: Dec 2008
Posts: 6
Reputation:
Solved Threads: 0
hi folks,
I'm writing a program for a punch press that displays the pattern to be punched. I have learned how to retrieve the data from a spreadsheet calculate the hole angles and draw them on my form
The basic pattern has multiple holes and is different for each process. As the machine runs it fills in the holes and changes colors.
My problem is when the form is minimized and then reopened all the graphics are gone. If the program is running then it keeps adding drawings to the screen but the prior screen drawings have been erased. How do i retain all the drawings that are getting placed on the screen when it is minimized. It's probably an asy answer but i'm new and going in the circles i'm trying to draw.
I'm writing a program for a punch press that displays the pattern to be punched. I have learned how to retrieve the data from a spreadsheet calculate the hole angles and draw them on my form
VB.NET Syntax (Toggle Plain Text)
{ Using g As Graphics = Me.CreateGraphics Dim pn As New Pen(Color.Crimson, 3) Dim circ As New Rectangle((xdrawloc), (ydrawloc), 12, 12) g.DrawEllipse(pn, circ) xloc.Add(xdrawloc) yloc.Add(ydrawloc) End Using}
My problem is when the form is minimized and then reopened all the graphics are gone. If the program is running then it keeps adding drawings to the screen but the prior screen drawings have been erased. How do i retain all the drawings that are getting placed on the screen when it is minimized. It's probably an asy answer but i'm new and going in the circles i'm trying to draw.
Last edited by Ancient Dragon; Jan 8th, 2009 at 8:56 pm. Reason: add code tags
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
Instead of using the form graphics use a bitmap and set the form background equal to the bitmap image. Now when you write to the bitmap it will be transfered automatically to the form background image. Otherwise you have to do all your drawing in the form paint event and call Form.Invalidate.
Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
create a new project and add this code. Start it with the window minimized.
VB.NET Syntax (Toggle Plain Text)
Public Class Form1 Private bmp As Bitmap = New Bitmap(100, 200, System.Drawing.Imaging.PixelFormat.Format32bppArgb) Private gr As Graphics = Graphics.FromImage(bmp) Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.BackgroundImageLayout = ImageLayout.None Me.BackgroundImage = bmp gr.FillEllipse(Brushes.Blue, New Rectangle(0, 0, 100, 200)) End Sub End Class
Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
•
•
Join Date: Dec 2008
Posts: 6
Reputation:
Solved Threads: 0
Thanks,Wayne
I'll give it a try. It's a very dynamic drawing containing up to 600 circle targets for several hundred different patterns. The code I have already wrote works so well until you minimize it then poof it's all gone. I guess it's part of the learning process. Your code did make the lights come on though and i can't wait to see the results. I'll hack on it some more tomorrow. Love west Virginia by the way spend a lot of time up at Cass, my wife and I are steam engine railroad fans
I'll give it a try. It's a very dynamic drawing containing up to 600 circle targets for several hundred different patterns. The code I have already wrote works so well until you minimize it then poof it's all gone. I guess it's part of the learning process. Your code did make the lights come on though and i can't wait to see the results. I'll hack on it some more tomorrow. Love west Virginia by the way spend a lot of time up at Cass, my wife and I are steam engine railroad fans
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
Yea, love Cass myself. This summer we are going to take the Mistery Train ride and see if I'm smart enought to solve the crime. I was away from West Virginia for 40 years and now I will never leave it again.
You might be able to put the code in Form.Paint but I think it will slow up your drawing because you have to keep drawing everything. With the bitmap you draw to it once and keep adding more. You don't need to draw anything you already drew.
If you can convert to drawing to bitmap I think in the long run it would be worth your extra time.
You might be able to put the code in Form.Paint but I think it will slow up your drawing because you have to keep drawing everything. With the bitmap you draw to it once and keep adding more. You don't need to draw anything you already drew.
If you can convert to drawing to bitmap I think in the long run it would be worth your extra time.
Last edited by waynespangler; Jan 7th, 2009 at 6:40 pm. Reason: can't spell
Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
•
•
Join Date: Dec 2008
Posts: 6
Reputation:
Solved Threads: 0
Got it!!!
Thanks for your help, ended up using a picturebox instead of writing on the form but it does retain it now that it is a bitmap and using the picturebox helped keep everything in order when changing aspect ratios. Now i've got to start integrating it to the machine. OPC time, back to the books. thanks again!!
Thanks for your help, ended up using a picturebox instead of writing on the form but it does retain it now that it is a bitmap and using the picturebox helped keep everything in order when changing aspect ratios. Now i've got to start integrating it to the machine. OPC time, back to the books. thanks again!!
![]() |
Similar Threads
- Toshiba Satellite A105-s101 Blank Screen (Windows NT / 2000 / XP)
- Retaining highest res. of a photo in upload? (ASP.NET)
Other Threads in the VB.NET Forum
- Previous Thread: vb.net 08 Reading data from multiple reg keys
- Next Thread: Datagridview select row and column
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account add application array basic beginner browser button buttons center check click code combo cpu crystalreport cuesent database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel exists fade file-dialog filter forms ftp generatetags html images input insert intel listview mobile module monitor mysql net number open output panel passingparameters picturebox picturebox2 port print printing printpreview problem regex reuse right-to-left searchvb.net select settings shutdown socket sqldatbase sqlserver storedprocedure survey tcp temperature textbox timespan transparency trim txttoxmlconverter user usercontol vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet vista visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode xml year





