Solved

Edit control

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 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 concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now