怎么设置vb文本框的行间距或者是richtextbox的行间距?????
展开全部
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
Private Const WM_USER = &H400
Private Const EM_GETPARAFORMAT = WM_USER + 61
Private Const EM_SETPARAFORMAT = WM_USER + 71
Private Const MAX_TAB_STOPS As Long = 32
Private Const PFM_LINESPACING As Long = 256
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 Sub Command1_Click()
Dim pf2 As PARAFORMAT2
Dim retval As Long
RichTextBox1.SelStart = Len(RichTextBox1.Text)
pf2.cbSize = LenB(pf2)
pf2.bLineSpacingRule = 3
pf2.dyLineSpacing = CLng(500 * Rnd) + 500 '指定500到1000twips随机行距
pf2.dwMask = PFM_LINESPACING
retval = SendMessage(RichTextBox1.hwnd, EM_SETPARAFORMAT, ByVal 0&, pf2)
End Sub
Private Sub Form_Load()
RichTextBox1.Text = RichTextBox1.Text & vbCrLf & "RichTextBox1"
End Sub
Private Const WM_USER = &H400
Private Const EM_GETPARAFORMAT = WM_USER + 61
Private Const EM_SETPARAFORMAT = WM_USER + 71
Private Const MAX_TAB_STOPS As Long = 32
Private Const PFM_LINESPACING As Long = 256
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 Sub Command1_Click()
Dim pf2 As PARAFORMAT2
Dim retval As Long
RichTextBox1.SelStart = Len(RichTextBox1.Text)
pf2.cbSize = LenB(pf2)
pf2.bLineSpacingRule = 3
pf2.dyLineSpacing = CLng(500 * Rnd) + 500 '指定500到1000twips随机行距
pf2.dwMask = PFM_LINESPACING
retval = SendMessage(RichTextBox1.hwnd, EM_SETPARAFORMAT, ByVal 0&, pf2)
End Sub
Private Sub Form_Load()
RichTextBox1.Text = RichTextBox1.Text & vbCrLf & "RichTextBox1"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询