Solved

Edit control

Posted on 2004-03-29
5
397 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

705 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