Solved

Edit control

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

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…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

738 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