答案来自问专家网站和CSDN的TechnoFantasy(www.applevb.com) ,解决如下:

Public Const WM_USER = &H400
Public Const EM_SETTARGETDEVICE = (WM_USER + 72)

Public Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
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 Sub AutoSwitchLine(ByRef RichText As Long, ByVal bSwitch As Boolean)
    If bSwitch Then
        '设置 RichTextBox 自动换行
        Call SendMessage(RichText.hWnd, EM_SETTARGETDEVICE, _
        GetDC(RichText.hWnd), RichText.Width / 15)
        If RichText.RightMargin = 0 Then
            RichText.RightMargin = 1
        Else
            RichText.RightMargin = 0
        End If
    Else
        '设置 RichTextBox 不自动换行
        Call SendMessage(RichText.hWnd, EM_SETTARGETDEVICE, 0, 1)
    End If
End Sub

相关文章:

  • 2022-12-23
  • 2021-11-26
  • 2021-07-22
  • 2022-01-06
  • 2021-04-21
  • 2021-04-08
  • 2021-10-20
猜你喜欢
  • 2022-02-07
  • 2022-02-07
  • 2022-12-23
  • 2021-08-28
  • 2021-10-18
相关资源
相似解决方案