|
-
Aug 28th, 2012, 08:30 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] VB6 - Check if a line (graphic) exists
I'm writting a code to create a grid inside the picturebox http://dret.net/lectures/web-spring09/img/grid.png
I want to check if a line has been already drawn.
I create a line called Line1(0). Then the program executes the funcion .
When I resize the form I call again to the function to add lines in the picturebox.
If I charge the line1(2) twice the programs shows the next error: "The object has been already charged".
I want to know 2 things:
A) How the program can knows if a line exists to prevent to charge it again
B) What I've to write to remove a line from the picturebox. If Load Line1(X) is to create, what is the opposite function that removes a specific line?
-
Aug 28th, 2012, 02:53 PM
#2
PowerPoster
Re: VB6 - Check if a line (graphic) exists
I want to know 2 things:
A) How the program can knows if a line exists to prevent to charge it again
B) What I've to write to remove a line from the picturebox. If Load Line1(X) is to create, what is the opposite function that removes a specific line?
A) You need to keep track of those objects that you've drawn. Line in this case.
B) It depends: You can redraw the picturebox without the line (either directly or from a back buffer), or
redraw the line ontop of itself with the background color. or
XOR the line.
If you opt for redrawing the line with the background color you will holes in any other objects if the line was drawn on-top of those objects. XORing the line will also create holes.
-
Aug 28th, 2012, 03:28 PM
#3
Re: VB6 - Check if a line (graphic) exists
Use LineName.Count property to know if that line is already loaded or not, for example if Line1.count = 2 then Line1(0) and Line1(1) are already loaded, if you need a 3rd line you'll have to Load Line1(2). Implementation depends on your code.
Load line1(line1.Count-1) will load the next line after the last one loaded.
-
Aug 28th, 2012, 06:49 PM
#4
Re: VB6 - Check if a line (graphic) exists
When I resize the form I call again to the function Load Line1(x)
Is this because if the Form get bigger you want to add more lines?
Then by same token if the Form get smaller would you want to remove lines?
If Load Line1(X) is to create, what is the opposite function that removes a specific line?
Unload Line1(x). I think un means to undo, don't you?
Last edited by jmsrickland; Aug 28th, 2012 at 06:54 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|