How to have transparent text label on top of picture box 
Author Message
 How to have transparent text label on top of picture box

I have a picture box control which will change pictures according to a
certain timed script and certain events trigger to change pictures. I
need to be able to place text over the picture, and then be able to
remove that text and replace it with other text without reloading the
picture box. I tried putting a label control on top of the picture box
and set its color to transparent in the designer, but that didn't
work. The label blocked out a rectangle on the picture.

I also need to overlay a moving graphical clock (stop-watch) over the
picture box. I have a VB6 control that shows a clock the way I need
it, but when I set its color to transparent I get an invalid property
value error.

How can I do this?



Tue, 08 Mar 2005 08:46:17 GMT  
 How to have transparent text label on top of picture box
I don't know why a transparent background color doesn't work with labels,
but you can do it with GDI+. Place this code in the picutre box's paint
event to see an example:

Dim g As Graphics = PictureBox1.CreateGraphics
Dim mybrush As New Drawing2D.LinearGradientBrush( _
    ClientRectangle, Color.Red, Color.Yellow, _
    Drawing2D.LinearGradientMode.Horizontal)
Dim myFont As New Font("Times New Roman", 24)
g.DrawString("Look at this text!", myFont, mybrush, 0, 0)

You can find more information by looking at the help under GDI+ Graphics,
"Drawing Text with GDI+", or highlighting some of the methods above in the
IDE, like "CreateGraphics" or "DrawString", and hitting F1.

You can also draw the graphical clock this way, but that could be a pain.You
could copy the image that the clock control creates to an image object, then
process the image by changing the background color to transparent, then draw
the new image onto your picture. Not sure how to do that but it should be
possible.

HTH,
Bob


Quote:
> I have a picture box control which will change pictures according to a
> certain timed script and certain events trigger to change pictures. I
> need to be able to place text over the picture, and then be able to
> remove that text and replace it with other text without reloading the
> picture box. I tried putting a label control on top of the picture box
> and set its color to transparent in the designer, but that didn't
> work. The label blocked out a rectangle on the picture.

> I also need to overlay a moving graphical clock (stop-watch) over the
> picture box. I have a VB6 control that shows a clock the way I need
> it, but when I set its color to transparent I get an invalid property
> value error.

> How can I do this?



Wed, 09 Mar 2005 02:56:01 GMT  
 How to have transparent text label on top of picture box
Hi Mark,

It won't work with a PictureBox but it will work if you use a Panel instead
and set the BackgroundImage of the Panel to be the image you want to
display. This is because .NET controls are transparent to their container.
Just be sure to put your label entirely inside the Panel.

HTH,

--
Jeff Rhodes
Author of "VBTrain.Net: Creating Computer and Web Based Training with Visual
Basic? .NET"
www.vbtrain.net
Home of the Shape and Graphical Text controls


Quote:
> I have a picture box control which will change pictures according to a
> certain timed script and certain events trigger to change pictures. I
> need to be able to place text over the picture, and then be able to
> remove that text and replace it with other text without reloading the
> picture box. I tried putting a label control on top of the picture box
> and set its color to transparent in the designer, but that didn't
> work. The label blocked out a rectangle on the picture.

> I also need to overlay a moving graphical clock (stop-watch) over the
> picture box. I have a VB6 control that shows a clock the way I need
> it, but when I set its color to transparent I get an invalid property
> value error.

> How can I do this?



Wed, 09 Mar 2005 13:32:18 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using Circle and Line on TOP of Labels/Text Boxes etc

2. Need API call or whatever to make label be on top of text box

3. How to have a transparent picture on top of other controls

4. label on top of a form picture

5. Newbie - Marking where user clicked on transparent label boxes

6. transparent and rotated label/textbox text

7. Forcing text to the top of an Text Box

8. Labels, Text Boxes, and ugly text

9. vb4: put tab chr(9) in label.caption or text box.text

10. Help with Manual Alignment of text in Text/Label boxes

11. Labels on top of Text

12. transparent OCX with transparent label

 

 
Powered by phpBB® Forum Software