I want to print outlined text in a picturebox, howto?
Printable View
I want to print outlined text in a picturebox, howto?
petrus,
can you describe what exactly are you after?
Yes, i can.
I want to type some text on a picturebox (with the print function), and i want to have a line around the text, just one pixel wide.
Do you understand now?
I understand now. Try this sample and let me know:
Dim strText As String
Dim X1, Y1, X2, Y2
Picture1.AutoRedraw = True
strText = "This a sample text"
Picture1.Print vbNewLine & vbTab & strText & vbNewLine & vbTab
X1 = Picture1.TextWidth(vbTab)
X2 = X1 + Picture1.TextWidth(strText)
Y1 = Picture1.TextHeight("T") * 2.5
Y2 = Y1
Picture1.Line (X1, Y1)-(X2, Y2)
Cheers, Roy
Sorry, forgot to include Picture1.DrawWidth = 2 as the second line
I know that I've seen that question answered before and fairly recently. Do a search for "text in picturebox" on this forum and on CodeGuru forum.
I've just searched the code, and to me it looks like it will just draw a line under it, but i will check again and test it! Thanx.
If what I gave isn't enough.
;-)
Yepp, it just draw a line under the text
So finish your rectangle by yourself. What's the problem. as a programmer you must not ask for an ready answer - but instead just for an idea and try to work arround it.
BTW, instead going into this sort of hassle I'd rather use a flat transparent label without border and shape control.
Cheers
How about this?VB Code:
Private Sub Command1_Click() Dim strText As String Dim X1, Y1, X2, Y2 Picture1.AutoRedraw = True strText = "This a sample text" Picture1.Print vbNewLine & vbTab & strText & vbNewLine & vbTab X1 = Picture1.TextWidth(vbTab) - Picture1.TextWidth(" ") X2 = X1 + Picture1.TextWidth(strText) + 2 * Picture1.TextWidth(" ") Y1 = Picture1.TextHeight("T") * 2.5 - Picture1.TextHeight("T") * 2: Y2 = Y1 Picture1.Line (X1, Y1)-(X2, Y2) Y2 = Picture1.TextHeight("T") * 2.5 Picture1.Line -(X2, Y2) Picture1.Line -(X1, Y2) Picture1.Line -(X1, Y1) End Sub
Can't do that.
How to fill letters? In the P letter, the circle at the top should be filled with some color.
yeah, I guess it would be really hard to use that code to make 3 more lines
Nicer way... (all the variables are calculated all together)
VB Code:
Private Sub Command1_Click() Dim strText As String Dim X1, Y1, X2, Y2 Picture1.AutoRedraw = True strText = "This a sample text" Picture1.Print vbNewLine & vbTab & strText & vbNewLine & vbTab X1 = Picture1.TextWidth(vbTab) - Picture1.TextWidth(" ") X2 = X1 + Picture1.TextWidth(strText) + 2 * Picture1.TextWidth(" ") Y1 = Picture1.TextHeight("T") * 2.5 - Picture1.TextHeight("T") * 2 Y2 = Picture1.TextHeight("T") * 2.5 Picture1.Line (X1, Y1)-(X2, Y1) Picture1.Line -(X2, Y2) Picture1.Line -(X1, Y2) Picture1.Line -(X1, Y1) End Sub
Sorry, but i think you missunderstood me.
I don't want a BOX around the text.
Check out my picture attached.
The black around the letter in the picture is what i want to do.
You need a Font Builder utility to do that. Fonts are contained of a small bitmaps and each character (which is predesigned) is been drawn for you by the system based on your current settings.
Not necessarily. You could play with your image to get what you want. Like I did in this example. Anyway... it's not that easy, and can't do it right now.
You won't be able to do this in the lifetime using VB.
;-)
I may be missing what you are trying to do but try this example and see if it works for you...
Wow!! Seems like someone could do it with VB!!Quote:
Originally posted by IROY55
You won't be able to do this in the lifetime using VB.
;-)
:)
You didn't miss anything James... that's what he was looking for.
And... by the way, it's as easy as I used to do it in QBasic.
Never noticed this :DQuote:
Originally posted by IROY55
You won't be able to do this in the lifetime using VB.
;-)
IROY55 : Times up !!! ;)
He, he..
That was nice, obviously didn't think about overlaying 2 messages.
;-)
Thats KOOL James :cool:
Not my code. Do not want to take the credit, but you are right, it is cool...:cool:Quote:
Originally posted by kinjalgp
Thats KOOL James :cool:
Thanx! That was exactly what i wanted!
Glad I could help... Edit you subject of your first post and add Resolved (proper way of doing it here, although no-one does ;) )Quote:
Originally posted by petrus
Thanx! That was exactly what i wanted!