|
-
Jul 27th, 2000, 11:15 PM
#1
Thread Starter
Addicted Member
I'm trying to develop a textbox that expands as the text in it wraps, but I am having difficulty figuring out a generic method for identifying the graphical width of a string without knowing the font that is being used.
I have read about the ClientDC.GetTextExtent method in C++. Is there something like that in VB? What properties should I be looking at?
I appreciate everyones' assistance.
Regards,
New2VB
-
Jul 28th, 2000, 12:04 AM
#2
Hyperactive Member
Hi,
Im not really sure if this will be of any help...but thought I'd tell u anyway.
There's an API GetTetExtentPoint - but I couldn't get any info on what it actually does.
hope this is what u were looking for.
-
Jul 28th, 2000, 05:00 AM
#3
Fanatic Member
Yep, that's the one:
Code:
'BAS Module
Public Declare Function GetTextExtentPoint Lib "gdi32" Alias "GetTextExtentPointA" (ByVal hdc As Long, ByVal lpszString As String, ByVal cbString As Long, lpSize As txtSize) As Long
Type TxtSize
x as Long
y as Long
End Type
'Form Module
'Me.ScaleMode = 3 Or Use Screen.TwipsPerPixel
...
Dim Size as txtSize
Dim Str as String
Str = Text1.Text
Call FindTextLength(Me.hDC, Str, LenB(Str), Size)
Text1.Width = Size.y
I think that'll do the trick.
I haven't tested it or anything so you might need to tweak it a bit.
Hope it helps,
Me
-
Jul 28th, 2000, 06:29 AM
#4
Addicted Member
Code:
Private Sub Text1_Change()
Dim MinWidth As Long
MinWidth = 256
Text1.Width = TextWidth(Text1.Text) + MinWidth
End Sub
Visual Basic 6 Enterprise Edition + SP4
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
|