Results 1 to 8 of 8

Thread: Disabling wordwrap in RichTextBoxes?

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2001
    Location
    England
    Posts
    36

    Disabling wordwrap in RichTextBoxes?

    I'm trying to open a log file to be displayed in a richtextbox and it works fine. The problem is, a lot of the lines go beyond the width of the richtextbox and automatically carriage return to the next (wordwrap). Is there a way of preventing this and forcing the user to use the horizontal scroll bar to see the entire line?

    Any help much appreciated.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Set the MultiLine property of the RichTextBox to False (unlike the standard text box, it is set to True by default)

  3. #3
    Addicted Member E-Link's Avatar
    Join Date
    Nov 2001
    Location
    INA
    Posts
    242
    Hi ,
    place the following code into a module...
    Code:
    Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lparam As Long) As Long
    Public Const WM_USER = &H400
    Public Const EM_SETTARGETDEVICE = (WM_USER + 72)
    then to set word wrap, use this :
    Code:
    SendMessageLong RichTextBox.hwnd, EM_SETTARGETDEVICE, 0, 0
    and to do the oposite use this one :
    Code:
    SendMessageLong RichTextBox.hwnd, EM_SETTARGETDEVICE, 0, 1

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Toggling the MultiLine property seems to be a litte less code intensive.

  5. #5
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    but Hack....

    WuzZ wants multiline...just wants the line to be really long (no word wrap)


    E-Link - Nice code.

    I used to set then Right margin to some ungodly number (like 500000) then it would work , unless they put a super long line in.

    Like your code better!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2001
    Location
    England
    Posts
    36
    Hack,

    Disabling the multiline property didn't work I'm afraid because there are multiple lines in the log file I'm using, hence only one line is displayed when this property is disabled.

    E-Link,

    I tried the code and it worked great.

    Cheers for the help guys.

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Hmmm...maybe next time I should try reading the question more carefully. Lol...I think I need more coffee...

  8. #8
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    he he
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width