|
-
Mar 8th, 2007, 12:10 PM
#1
Thread Starter
Member
Fonts
Is there a way to change the "safe area" on the top and bottom of a font?
What I want to do is this: I have a label that is multilined, but there is a lot of space between the lines since I am using a large font. I would like to trim off a little of the safe area at the top and bottom of the font so the words get 'squished' closer togeter.
Any thoughts or suggestions?
-
Mar 8th, 2007, 01:00 PM
#2
Re: Fonts
you could just print the text straight to the form in the position you want
-
Mar 8th, 2007, 02:00 PM
#3
Line Spacing in RichTextBox
You can use a RichTextBox and set custom LineSpacing.
See the code below.
(Note: This code most likely will NOT work on Windos98/Me)
vb Code:
' add a RichTextBox, a Textbox and a CommandButton in a form.
' Type the line-spacing you want (in twips) in the textbox
' and hit the command button
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal HWND As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_USER = &H400
Const EM_GETPARAFORMAT As Long = (WM_USER + 61)
Const EM_SETPARAFORMAT = WM_USER + 71
Const PFM_LINESPACING As Long = &H100
Const MAX_TAB_STOPS = 32
Private Type PARAFORMAT2
cbSize As Long
dwMask As Long
wNumbering As Integer
wEffects As Integer
dxStartIndent As Long
dxRightIndent As Long
dxOffset As Long
wAlignment As Integer
cTabCount As Integer
rgxTabs(MAX_TAB_STOPS - 1) As Long
dySpaceBefore As Long
dySpaceAfter As Long
dyLineSpacing As Long
sStyle As Integer
bLineSpacingRule As Byte
bOutlineLevel As Byte
wShadingWeight As Integer
wShadingStyle As Integer
wNumberingStart As Integer
wNumberingStyle As Integer
wNumberingTab As Integer
wBorderSpace As Integer
wBorderWidth As Integer
wBorders As Integer
End Type
Private Function SetLineSpacing(lHwnd As Long, LineSpacingInTwips As Long)
Dim pf2 As PARAFORMAT2
Dim lR As Long
pf2.cbSize = Len(pf2)
SendMessage lHwnd, EM_GETPARAFORMAT, 0&, pf2
'
pf2.dwMask = PFM_LINESPACING
pf2.bLineSpacingRule = 4
pf2.dyLineSpacing = LineSpacingInTwips
pf2.cbSize = Len(pf2)
SendMessage lHwnd, EM_SETPARAFORMAT, 0, pf2
End Function
Private Sub Command1_Click()
RichTextBox1.SelStart = 0
RichTextBox1.SelLength = Len(RichTextBox1.Text)
SetLineSpacing RichTextBox1.HWND, Val(Text1.Text)
RichTextBox1.SelLength = 0
End Sub
Private Sub Form_Load()
Text1.Text = 170 'this value looks good in my comp
End Sub
-
Mar 8th, 2007, 05:13 PM
#4
Re: Fonts
If the label is going to have rather constant, unchanging text length, use two labels in transparent back color instead of one and divide the caption text. Then squeeze the position of the lower one up closer to the one above by adjusting the Top value. It's an old trick but it works.
-
Mar 8th, 2007, 05:16 PM
#5
Re: Fonts
Ahhh...I totally overlooked the 'label' part. 
Sorry for making things convoluted.
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
|