将RichTextBox设置为自动换行或非自动换行

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 aspbit 的 blog

  近日研究文本控件和字符串,研究得头混脑胀,问题真是太多了。
  这只是其中的一个问题,答案来自问专家网站和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

本文关键:自动换行、RichTextBox
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top