Click to See Complete Forum and Search --> : ScrollBar question
Abulehleh
September 23rd, 2006, 04:19 AM
I got an multilined edit box with a "WS_VSCROLL", but when it recieves data after the regular visiable space, the scrollbar becomes accessiable, but i want the scrollbar to automatically get as down as he can (like in icq, when you write something)..
can anybody help me plz?
thanks!
gecka
September 23rd, 2006, 04:24 AM
Did you use ES_MULTILINE for your edit control?
Abulehleh
September 23rd, 2006, 12:00 PM
yes, i said before it's multilined..
any suggestions?
gecka
September 23rd, 2006, 12:07 PM
Please post your edit control creation code.
Abulehleh
September 23rd, 2006, 04:55 PM
Oh, sorry, sure:
HWND edit1 = CreateWindowEx
( WS_EX_CLIENTEDGE,
"EDIT",
NULL,
WS_CHILD | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL | WS_VSCROLL | WS_VISIBLE | WS_BORDER | DS_CENTER,
6, 6, 268, 136,
hwnd,
(HMENU)MSG_BOARD,
NULL, 0 );
WS_CHILD - because it's a child..
ES_MULTILINE - for multilined use..
ES_AUTOHSCROLL - automatically horizonal scrolling..
ES_AUTOVSCROLL - automatically vertical scrolling..
ES_VSCROLL - vertical scroll bar (the one that sould automatically go to the botton)..
WS_VISIBLE - ...
WS_BORDER - that the window will have borders..
DS_CENTER - so even if the window is enabled, it cant be written on, and it's default color is light gray..
HELP..??
Zaccheus
September 23rd, 2006, 06:15 PM
You can tell the edit box to "scroll down" by a number of lines:
SendMessage(edit1, EM_LINESCROLL, 0, numberOfLinesToScroll);
You will need to calculate numberOfLinesToScroll, but this should probably be the number of lines which have just been added to the text box.
See also:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/editcontrols/editcontrolreference/editcontrolmessages/em_linescroll.asp
I hope this helps.
greg_dolley
September 23rd, 2006, 09:01 PM
You will need to calculate numberOfLinesToScroll, but this should probably be the number of lines which have just been added to the text box.
Remember to minus the number of lines that are already visible because that control might give you an error if you try to scroll past the end. But then again, it might do a bounds check; try it and see. :)
Greg Dolley
gecka
September 24th, 2006, 03:42 AM
A simple solution: remove ES_AUTOHSCROLL... :)
Abulehleh
September 24th, 2006, 05:25 PM
gecka, you mean the autoVscroll yes..?
anyway, it didn't help (i tryed taking one of the autoscrolls or both and the problem remains..)
any other suggestions?
Zaccheus
September 25th, 2006, 03:20 AM
Didn't EM_LINESCROLL work? :confused:
gecka
September 25th, 2006, 05:09 AM
I just took your code, pasted it in Dev-C++, removed ES_AUTOHSCROLL and it worked fine for me...
Or maybe you want it to scroll down when it receives text using WM_SETTEXT message?... :ehh:
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.