Call this function to determine the topmost visible line in an edit control.

int GetFirstVisibleLine( ) const;

The zero-based index of the topmost visible line. For single-line edit controls, the return value is 0.

For more information, see EM_GETFIRSTVISIBLELINE in the Windows SDK.

int nFirstVisible = m_myEdit.GetFirstVisibleLine();

// Scroll the edit control so that the first visible line 
// is the first line of text. 
if (nFirstVisible > 0)
   m_myEdit.LineScroll(-nFirstVisible, 0);

Header: afxwin.h

Community Additions