Set and unwrap in RichTextBox

Source: Internet
Author: User

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 RichTextBox, byval bswitch as Boolean)
If bswitch then
'Set RichTextBox to wrap automatically
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
'Set RichTextBox not to wrap automatically
Call sendmessage (richtext. hwnd, em_settargetdevice, 0, 1)
End if
End sub

Call method:
Autoswitchline richtextbox1, false
The above Code makes richtextbox1 not automatically wrap.

The above is a more formal method. If it is simple, the following two sentences of code can be used:

Richtextbox1.multiline = true
Richtextbox1.rightmargin = 10000

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.