|
-
Nov 23rd, 2000, 11:19 PM
#1
Thread Starter
New Member
I need to create some buttons where there is a label inside a picturebox. At design time, I have no problems: I create them seperately then cut and paste the label into the picturebox.
I tried the run-time creation of similar buttons using the
Load Picture1(i)
Load Label1(i)
methods but this makes them seperate and subsequently the text is hidden by the image. How do I fix this?
I would also like to know how, in general, you put text over pictures.
Bye
Elwyn
-
Nov 24th, 2000, 06:13 AM
#2
You need to setthe parent property of the labels to be the picture box, cos they are by default the form.
Just change the handles I think
- gaffa
-
Nov 24th, 2000, 07:11 AM
#3
New Member
hmmm....
I think you can put text over picture boxes by using a text box or label.
Then after creating the text box/label, just specify the co-ordinates you want it on the picture using the .Move X,Y method.
-
Nov 24th, 2000, 08:30 AM
#4
Sort of.
Labels a re window less controls (they have no hWnd property), and as such are always last in the ZOrder, so you need to make the paretn of the lable is a container (the pic box in this case)
- gaffa
-
Nov 25th, 2000, 11:02 PM
#5
Thread Starter
New Member
How do I set the parent property? I tried this and it generated an error.
Private Sub Command1_Click()
Load Form1.Picture1(1)
Load Form1.Label1(1)
Form1.Picture1(1).Top = 0
Form1.Picture1(1).Left = 0
Form1.Picture1(1).Visible = True
Form1.Label1(1).Left = 0
Form1.Label1(1).Top = 0
Form1.Label1(1).Visible = True
Form1.Label1(1).Parent = Form1.Picture1(1)
End Sub
Would I be better off creating my own ActiveX control since it would have encapsulation?
-
Nov 26th, 2000, 12:08 AM
#6
Fanatic Member
TextOut
How about using the API function TextOut to accomplish this.....
Code:
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
Private Sub Form_Load()
Picture1.Picture = LoadPicture("C:\Windows\Clouds.bmp")
End Sub
Private Sub Picture1_Paint()
Dim lRet As Long
Dim sDisp As String
Dim lStrLen As Integer
Dim iX As Integer, iY As Integer
' Convert Coordinates to Pixels
iX = Form1.ScaleX(60, vbTwips, vbPixels)
iY = Form1.ScaleY(60, vbTwips, vbPixels)
sDisp = "Clouds" ' Text to display in Picture Box
lStrLen = Len(sDisp) ' Length of string
lRet = TextOut(Picture1.hdc, iX, iX, sDisp, lStrLen)
End Sub
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Nov 26th, 2000, 02:30 AM
#7
Thread Starter
New Member
TextOut seems neat but does it allow the font name, font size (etc) to be set?
Anyway, I've been working on the ActiveX control version this afternoon.
My two current problems I have so far are:
a) that I don't know why the mouseUp event isn't being called after the user releases the mouse button
b) I don't know how to get the ActiveX component to tell the form what to do when it receives a mouseDown event
-
Nov 26th, 2000, 04:56 AM
#8
Fanatic Member
TextOut uses the current font, font size, font color, etc. when used with a Picture Box or Form.
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Nov 26th, 2000, 12:23 PM
#9
Or use the Print method.
Code:
Private Sub Command1_Click()
Picture1.ForeColor = vbRed
Picture1.FontName = "Courier New"
Picture1.Print "GDFGFD"
End Sub
Private Sub Command2_Click()
Picture1.ForeColor = vbBlue
Picture1.FontName = "Times New Roman"
Picture1.Print "FDSDSFS"
End Sub
-
Nov 26th, 2000, 12:40 PM
#10
Frenzied Member
I had the same problem.
All you have to do is put on in it (before running) you can make in invisible if you want. Then, during runtime:
Code:
Load Label(Label.Count)
Label(Label.Count - 1).Visible = True
Label(Label.Count - 1).Caption = "Markman is the best!"
Label(Label.Count - 1).Top = Label(Label.Count - 2).Top _ + Label(Label.Count - 2).Height
It workd for me.
You can even put a loop around it:
Do
'what it says above
Loop Until Label.Count = 10
retired member. Thanks for everything 
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
|