分享

将RichTextBox设置为自动换行

 悟静 2009-07-26
日研究文本控件和字符串,研究得头混脑胀,问题真是太多了。
  这只是其中的一个问题,答案来自问专家网站和CSDN的,解决如下:

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

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约