vb.net的RichTextbox调整行距

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,快我调试了许久也没有成功,请大侠帮帮忙看看,错在哪里,要写成怎样 先谢谢了

把sendmessage改成postmessage试一试追问

还是显示 System.ArgumentException:“值不在预期的范围内。”

追答

调试运行的结果呢?停在哪行代码上了?

追问

Call SendMessage(hn, EM_SETPARAFORMAT, 0, x)
提示System.ArgumentException:“值不在预期的范围内。”

追答

那就重点检查 PARAFORMAT2结构是否有问题, PARAFORMAT2结构的大小是否有问题!

追问

PARAFORMAT2结构我弄不明白,你能帮我看看吗。
这个问题没有解决,新的问题又来了,你好,请帮个忙,先谢谢
vb.net中的richtextbox控件如何设置字体的大小,richtextbox中有三种字体,我的意思是不改变字体只是改变字体的大小。如何实现。如vb6对选中的文字只要执行richtextbox.Font.Size就可以了,我对vb.net刚接触,希望详细点,谢谢。

追答

抱歉,我一直在坚持使用vb6.0,没有安装net环境!没法帮你调试,只有你自己尝试调试了!

温馨提示:内容为网友见解,仅供参考
无其他回答

Warning: Invalid argument supplied for foreach() in /www/wwwroot/www.t2y.org3v3b34/skin/templets/default/contents.html on line 47
相似回答