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