tags:

views:

472

answers:

3

In a VC++ 6.0 MFC of mine, I added an EditBox with Vertical Scrollbar, every 10 seconds I am reading data from serial port and I have to display through EditBox(IDC_EDIT1), I done it without any problems.

But one typical problem I am facing which is that, whenever a new data displayed in the EditBox the vertical scrollbar goes up and data remains down, I have to scroll down every time to read the data.

So my question is whenever a new data display in EditBox the vertical scrollbar also has to move down along with the data.

How can i do this?

+1  A: 

You will need to send the edit control an EM_SETSEL message with the length of the string as the parameters.

Tommy Hui
SORRY I DID'T GET UR POINT,I AM DISPLAYING DATE AND TIME IN EDIT BOX ,
+1  A: 

Also if your EditBox is CEdit, you can try following its member functions void SetSel( DWORD dwSelection, BOOL bNoScroll = FALSE ); void SetSel( int nStartChar, int nEndChar, BOOL bNoScroll = FALSE );

sesame
A: 

You can send a message to the control:

SendMessage(hwnd, WM_VSCROLL, SB_BOTTOM, 0);

where hwnd is the handle of your editbox

Scoregraphic