?
Solved

Edit control

Posted on 2004-03-29
5
Medium Priority
?
404 Views
Last Modified: 2010-05-18
I have Edit control in Win32application not MFC. I keep appending text to display in the control, and I need to scroll the Edit controll automatically to make the last line of text always visible.I used the setscrollpos() function the scroll bar moves to the end but the text in the window does not.
thanks
0
Comment
Question by:gerstla
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
wayside earned 500 total points
ID: 10703736
After you append the text in the edit box, send it an EM_LINESCROLL message.

From MSDN:

The EM_LINESCROLL message scrolls the text in a multiline edit control.

Syntax

To send this message, call the SendMessage function as follows.

lResult = SendMessage(      // returns LRESULT in lResult
        (HWND) hWndControl,      // handle to destination control
        (UINT) EM_LINESCROLL,      // message ID
        (WPARAM) wParam,      // = (WPARAM) () wParam;
        (LPARAM) lParam      // = (LPARAM) () lParam; );  
Parameters

wParam
Edit controls: Specifies the number of characters to scroll horizontally.
Rich edit controls: This parameter is not used; it must be zero.

lParam
Specifies the number of lines to scroll vertically.
Return Value

If the message is sent to a multiline edit control, the return value is TRUE.
If the message is sent to a single-line edit control, the return value is FALSE.



Remarks

The control does not scroll vertically past the last line of text in the edit control. If the current line plus the number of lines specified by the lParam parameter exceeds the total number of lines in the edit control, the value is adjusted so that the last line of the edit control is scrolled to the top of the edit-control window.

Edit controls: The EM_LINESCROLL message scrolls the text vertically or horizontally in a multiline edit control. The EM_LINESCROLL message can be used to scroll horizontally past the last character of any line.

0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 10703746
You have to set the caret (text cursor) to end of text using

   PostMessage(hWndEdit, EM_SETSEL, len, len);

where len is the length of your text.

Regards, Alex
0
 
LVL 14

Expert Comment

by:wayside
ID: 10703781
You might also be able to send the edit box a WM_VSCROLL message using SB_BOTTOM.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question