設置RichTextBox行距

'--- module ---
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_USER = &H400
Public Const EM_GETPARAFORMAT = WM_USER + 61
Public Const EM_SETPARAFORMAT = WM_USER + 71
Public Const MAX_TAB_STOPS As Long = 32
Public Const PFM_LINESPACING As Long = 256
Public 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


'--- form ---
'设form上有:RichTextBox(rt)
Private Sub Form_Load()
    rt.Text = "welcome to my company,glad" & vbCrLf & "abcdefghijklmnopqrstuvwxyz"
        Dim pf2 As PARAFORMAT2
    Dim retval As Long
    rt.SelStart = Len(rt)
    pf2.cbSize = LenB(pf2)
    pf2.bLineSpacingRule = 4
    pf2.dyLineSpacing = CLng(500 * Rnd) - 70
    pf2.dwMask = PFM_LINESPACING
    retval = SendMessage(rt.hwnd, EM_SETPARAFORMAT, ByVal 0&, pf2)
End Sub


posted @ 2007-06-16 10:25  TangHuawei  阅读(3514)  评论(3编辑  收藏  举报