Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating scrollbar in editbox ...

Status
Not open for further replies.

HadiRezaee

Technical User
Mar 9, 2001
165
IR
Hi all,
I have Editbox in my program ...
I want to update scrollbar in Editbox in each adding text into editbox ...
For example:
If my Text lines in EditBox was 200 lines, then my scrollbar must update in last position of scroll bar ...
And must show last line of text automatically ...
I wrote some code with SetScrollRange and SetScrollPos, but my code won't work ...

Please help me ...
 
There are several ways you can handle scrolling depending on the situation.

In this case it sounds like all you need is to send a message to the edit control telling it to scroll. There are various messages for this depending on if you want to scroll to a specific line or to the current caret position. For example if you wanted to scroll the text a certain number of lines, you could write:

SendMessage(hWnd, EM_LINESCROLL, 0, numLines);

But in order to do what I think you are trying to do you might need to first figure out how many lines you need to scroll, possibly search the text, etc and which might involve some combination of messages. Look at messages like:

EM_GETFIRSTVISIBLELINE
EM_GETLINE
EM_GETLINECOUNT
EM_LINEFROMCHAR
EM_LINEINDEX
EM_LINELENGTH
EM_LINESCROLL
EM_SCROLL
EM_SCROLLCARET

The other way to do scrolling is to deal with the scrollbar of the control itself which involves getting and setting the parameters of a SCROLLINFO struct but I doubt you need to do that in this case.

Look at the msdn library under
for details on all this stuff.

--Will Duty
wduty@radicalfringe.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top