# 拜托小吴,试了好久的问题 ?

Posted by Linkii on February 11, 1999 at 21:18:45:

小吴,我已经试了好久,能否指导下列程式的错误,谢谢!
我想在 RichTextBox做格式的定位.

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

Private Const WM_USER = &H400
Private Const EM_SETPARAFORMAT = WM_USER + 71
Private Const MAX_TAB_STOPS = 32
Private Const PFM_STARTINDENT = &H1
Private Const PFM_RIGHTINDENT = &H2
Private Const PFM_OFFSET = &H4
Private Const PFM_ALIGNMENT = &H8
Private Const PFM_TABSTOPS = &H10
Private Const PFM_NUMBERING = &H20
Private Const PFM_OFFSETINDENT = &H80000000

Private Type ParaFormat
cbSize As Integer
wPad1 As Long
dwMask As Long
wNumbering As Integer
wReserved As Integer
dxStartIndent As Long
dxRightIndent As Long
dxOffset As Long
wAlignment As Integer
cTabCount As Byte
rgxTabs(0 To MAX_TAB_STOPS - 1) As Long
End Type

Dim StructFormat As ParaFormat

Private Sub Command1_Click()
Dim result As Long
result = SendMessage(Text1.hwnd, EM_SETPARAFORMAT, 0&, StructFormat)
Text1.Text = Chr(9) & "the" & Chr(9) & "is" & Chr(9) & "a" & Chr(9) & "dog" & vbCrLf
Text1.Text = Text1.Text & Chr(9) & "te" & Chr(9) & "i" & Chr(9) & "afdf" & Chr(9) & "dog" & vbCrLf
Me.Caption = result
End Sub

Private Sub Form_Load()
StructFormat.cbSize = Len(StructFormat)
StructFormat.dwMask = PFM_TABSTOPS
StructFormat.cTabCount = 4
StructFormat.rgxTabs(0) = 48 * Screen.TwipsPerPixelX
StructFormat.rgxTabs(1) = 96 * Screen.TwipsPerPixelX
StructFormat.rgxTabs(2) = 144 * Screen.TwipsPerPixelX
StructFormat.rgxTabs(3) = 192 * Screen.TwipsPerPixelX
End Sub

Follow Ups:

- 宣告有错啦 CWW 11:16:25 2/12/99 (1)
  - Re: 宣告有错啦 Linkii 12:32:49 2/22/99 (0)