Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transparent Layer

Status
Not open for further replies.

Panthaur

IS-IT--Management
Jul 26, 2002
78
US
I am working on an application where it is necessary to be able to identify a small part of a design. The designs being displayed are drawn based on a text file which is simply x,y coordinates.

I want to be able to click on one X,Y coordinate and have the program highlight that point, but, I want to be able to do it with a transparent layer so that I don't actually disturb the actual design and have to worry about redrawing it each and every time.

So, my question is this: How do you make a picture box's background color transparent so that a picture box below it can show thru, thus allowing you to draw on the transparent picture box without affecting the picture box below it where the design is actually displayed?

Thanks for the help,
Panthaur
 
are you just using an image to highlight the point? VB's image control provides a transparent background, and should be able to do everything you're looking for, as long as the actual picture format supports transparency.
 
No, I'm actually going to be drawing on the transparent layer, so as far as I can tell, it pretty much needs to be a picture box. I want to eventually add the capability for the users to be able to hightlight a portion of the designs x,y code, like 10 lines, 20 lines, etc... and have the program higlight the points and draw lines from each point to the next.
 
In thatcase, I think you're in the same boat I am. I've been looking fo a way to make the background of a progessbar transparent, but I've yet to find anything. I assume there's some obscure, roundabout way of doing it through the API, but I haven't found anything yet...
 
I think that BitBlt might do the job, but I haven't a clue how to use it and I can't find any good information on it.
 
Ok, this might work for you.

Make 2 picture boxes, with exactly the same stuff in them. Have the box you want to keep pristine on top. Then, when the user starts to draw on that box, bung it to the back and let the user draw on the other box. When the user is done, let them click a command button or whatever, and restore your pristine box to the top. Here's a little code that I did to check the concept, and it looks like it might do what you want. Picture 1 is the pristine box, picture 2 is the "sand" box.

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Picture1.Zorder 1
End If
End Sub

Private Sub Picture2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Picture2.line -(x,y)
End If
End Sub

Private Sub Command1_Click()
Picture2.ZOrder 1
End Sub

HTH

Bob Rodes
 
Hi Bob,

Unfortunately, some of the designs that I am displaying are too large for me to enable the AutoRedraw function of the picture box, so I would wind up having to re-draw 2 different picture boxes instead of the one that I am doing now. In some cases, the designs go relatively quick, but if I have a design that has 30,000 points in it, redrawing can take up to 10 seconds, and if I do it on 2 pictureboxes, that time increases to about 20 seconds.

So unfortunately, this wouldn't work unless I was able to get the auto-redraw to work with oversized designs. Does anyone know what the maximum limits of an image in a picture box for the autoredraw function is before it crashes due to an image being too large?

Thanks for the idea though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top