Solved

Edit control

Posted on 2004-03-29
5
395 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
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
wayside earned 125 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

828 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