vb.net的RichTextbox调整行距
PrivateDeclareFunctionSendMessageLib"user32"Alias"SendMessageA"(ByValhwndAsLong,ByVal...
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As PARAFORMAT2) As Long
Const WM_USER = &H400
Const PFM_LINESPACING = &H100
Const MAX_TAB_STOPS = 32
Const EM_SETPARAFORMAT = WM_USER + 71
Structure PARAFORMAT2
Dim cbSize As Integer
Dim wPad1 As Integer
Dim dwMask As Long
Dim wNumbering As Integer
Dim wReserved As Integer
Dim dxStartIndent As Long
Dim dxRightIndent As Long
Dim dxOffset As Long
Dim wAlignment As Integer
Dim cTabCount As Integer
Dim lTabStops() As Long
Dim dySpaceBefore As Long
Dim dySpaceAfter As Long
Dim dyLineSpacing As Long
Dim sStyle As Integer
Dim bLineSpacingRule As Byte
Dim bCRC As Byte
Dim wShadingWeight As Integer
Dim wShadingStyle As Integer
Dim wNumberingStart As Integer
Dim wNumberingStyle As Integer
Dim wNumberingTab As Integer
Dim wBorderSpace As Integer
Dim wBorderWidth As Integer
Dim wBorders As Integer
End Structure
Public Sub RicHangJ(ByVal RicTxt As Object, ByVal Doi As Double) '设定Richtextbox行间距
Dim x As PARAFORMAT2
ReDim x.lTabStops(0 To MAX_TAB_STOPS - 1)
With RicTxt
.HideSelection = True
.SelectionStart = 0
.SelectionLength = Len(.Text)
x.cbSize = Len(x)
x.dwMask = PFM_LINESPACING
x.bLineSpacingRule = 5
x.dyLineSpacing = Doi * 20
Dim hn As Long = Val(.Handle.ToString)
Call SendMessage(hn, EM_SETPARAFORMAT, 0, x)
.SelectionStart = 0
.HideSelection = False '失去焦点时被选文字是否高亮显示F为是
End With
End Sub
上面这段代码是我从vb6.0中移动到vb.net,快我调试了许久也没有成功,请大侠帮帮忙看看,错在哪里,要写成怎样 先谢谢了 展开
Const WM_USER = &H400
Const PFM_LINESPACING = &H100
Const MAX_TAB_STOPS = 32
Const EM_SETPARAFORMAT = WM_USER + 71
Structure PARAFORMAT2
Dim cbSize As Integer
Dim wPad1 As Integer
Dim dwMask As Long
Dim wNumbering As Integer
Dim wReserved As Integer
Dim dxStartIndent As Long
Dim dxRightIndent As Long
Dim dxOffset As Long
Dim wAlignment As Integer
Dim cTabCount As Integer
Dim lTabStops() As Long
Dim dySpaceBefore As Long
Dim dySpaceAfter As Long
Dim dyLineSpacing As Long
Dim sStyle As Integer
Dim bLineSpacingRule As Byte
Dim bCRC As Byte
Dim wShadingWeight As Integer
Dim wShadingStyle As Integer
Dim wNumberingStart As Integer
Dim wNumberingStyle As Integer
Dim wNumberingTab As Integer
Dim wBorderSpace As Integer
Dim wBorderWidth As Integer
Dim wBorders As Integer
End Structure
Public Sub RicHangJ(ByVal RicTxt As Object, ByVal Doi As Double) '设定Richtextbox行间距
Dim x As PARAFORMAT2
ReDim x.lTabStops(0 To MAX_TAB_STOPS - 1)
With RicTxt
.HideSelection = True
.SelectionStart = 0
.SelectionLength = Len(.Text)
x.cbSize = Len(x)
x.dwMask = PFM_LINESPACING
x.bLineSpacingRule = 5
x.dyLineSpacing = Doi * 20
Dim hn As Long = Val(.Handle.ToString)
Call SendMessage(hn, EM_SETPARAFORMAT, 0, x)
.SelectionStart = 0
.HideSelection = False '失去焦点时被选文字是否高亮显示F为是
End With
End Sub
上面这段代码是我从vb6.0中移动到vb.net,快我调试了许久也没有成功,请大侠帮帮忙看看,错在哪里,要写成怎样 先谢谢了 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询