SHOW label on picturebox

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

SHOW label on picturebox

Post by sal21 »

I just have loaded an image in picturebox.
Now i need to show a label on image, possible.
I just tested to set the label bring to the front, but i dont see anthing!

i'm on VB6

User avatar
HansV
Administrator
Posts: 78235
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SHOW label on picturebox

Post by HansV »

Have you tried using a text box instead of a label?

Or place this code at the top of the form module:

Code: Select all

Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" _
    (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, _
    ByVal lpString As String, ByVal nCount As Long) As Long
and use code like this to draw text on the picture box:

Code: Select all

    Dim sText As String
    sText = "This is my text"
    TextOut Me.Picture1.hdc, 5, 10, sText, Len(sText)
where Picture1 is the name of the picture box.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

Re: SHOW label on picturebox

Post by sal21 »

Ok
But i need to use a mousemove on text, i can?

User avatar
HansV
Administrator
Posts: 78235
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SHOW label on picturebox

Post by HansV »

No, that won't work if you use TextOut.
Have you tried using a text box?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

Re: SHOW label on picturebox

Post by sal21 »

HansV wrote:
06 Jan 2021, 16:24
No, that won't work if you use TextOut.
Have you tried using a text box?
NO, not tested with textbox, but i need a trasparent textbox i dont want to cover any part of image.

User avatar
HansV
Administrator
Posts: 78235
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SHOW label on picturebox

Post by HansV »

You can set the background style of the text box to Transparent.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

Re: SHOW label on picturebox

Post by sal21 »

HansV wrote:
06 Jan 2021, 16:50
You can set the background style of the text box to Transparent.
hummmmm.
I dont see in any part of property Transparent option.
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78235
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SHOW label on picturebox

Post by HansV »

Best wishes,
Hans