Valhalla Legends Forums Archive | Visual Basic Programming | Non-wordwrapped (Rich)TextBox with no HScroll

AuthorMessageTime
Spht
Without creating my own RichEdit window through API, how would I go about modifying the properties of a (Rich)TextBox? The ideal result which I am trying to accomplish is a (Rich)TextBox which has no visible scroll bars, is multilined, and has automatic horizontal scrolling.

By default, the only way you can disable word wrapping on a (Rich)TextBox is by enabling a visible horizontal scrollbar.

I tried doing MyVar = GetWindowLong(.hWnd, GWL_STYLE), then adding ES_AUTOVSCROLL + ES_AUTOHSCROLL, then applying new flags with SetWindowLong, but it appears to have no effect.

Edit - By (Rich)TextBox, I mean that I will accept an answer using a RichTextBox or TextBox.

Thanks.
November 24, 2003, 8:57 PM
ObsidianWolf
This is a rough idea, but perhaps capture the amount of data perline and only show what would fit one line, having the rest dumped if you dont need it. Easily done with terminal font.
November 25, 2003, 11:33 PM
Adron
You probably have to remove WS_VSCROLL from the style. It's also a bad idea to add styles using + (addition). If the window already has that style, you'll be removing it and adding some other style.


SetWindowLong .hWnd, GWL_STYLE, GetWindowLong(.hWnd, GWL_STYLE) And Not WS_VSCROLL Or ES_AUTOHSCROLL Or ES_AUTOVSCROLL

May need some parenthesis, not sure about VB operator precedence. It's also possible that it's too late to change the scroll bars using window style after the window has already been created.
November 28, 2003, 11:15 AM
Spht
[quote author=Adron link=board=31;threadid=3820;start=0#msg32211 date=1070018128]
You probably have to remove WS_VSCROLL from the style. It's also a bad idea to add styles using + (addition). If the window already has that style, you'll be removing it and adding some other style.
[/quote]

I wasn't actually using +.

[quote author=Adron link=board=31;threadid=3820;start=0#msg32211 date=1070018128]
SetWindowLong .hWnd, GWL_STYLE, GetWindowLong(.hWnd, GWL_STYLE) And Not WS_VSCROLL Or ES_AUTOHSCROLL Or ES_AUTOVSCROLL
[/quote]

Had no effect.

[quote author=Adron link=board=31;threadid=3820;start=0#msg32211 date=1070018128]
It's also possible that it's too late to change the scroll bars using window style after the window has already been created.
[/quote]

Yeah, I'm beginning to think that too. I've tried many variations of modifying its styles but none work. The only solution may be to create the window myself at run-time -- I was hoping that I wouldn't have to do that though. Is there an alternative?
November 28, 2003, 4:11 PM
Spht
Adron introduced ShowScrollBar() to me. As a reference for anyone who is having this problem in the future, call ShowScrollBar(hWnd, wBar, bShow).

hWnd is the handle of your (Rich)TextBox.

wBar supplies the scrollbar to show/hide:
Const SB_VERT = 1
Const SB_HORZ = 0

bShow (true/false) toggles visibility of scroll bar.
November 28, 2003, 4:48 PM
MesiaH
Damn, beat again by adron.. DAMN U STEALING ALL OF MY POSTS!!

jk jk, but yeah, i have a list of about every API Call and every constant used for richtextbox, theres some really neat things you can do with them (things i thought werent possible) its not such a bad thing to have layin around...

also, if u know how to put an image into an rtb, without using the clipboard, gogogogo share. :P
December 2, 2003, 6:41 AM

Search