楼上的方法for rich edit不过楼上的方法可以用吧。。没试过The EM_GETSELTEXT message retrieves the currently selected text in a rich edit control.EM_GETSELTEXT wParam = 0; lParam = (LPARAM) (LPSTR) lpBuf;
Parameters lpBuf Pointer to a buffer that receives the selected text. The calling application must ensure that the buffer is large enough to hold the selected text. Return Values Returns the number of characters copied, not including the terminating null character.
INT nEnd = 20;
TCHAR* buffer = new TCHAR[21];
::SendMessage( m_CEdit.m_hWnd, EM_SETSEL, nStart, nEnd );
::SendMessage( m_CEdit.m_hWnd, EM_GETSELTEXT, 0, buffer );
wParam = 0;
lParam = (LPARAM) (LPSTR) lpBuf;
Parameters
lpBuf
Pointer to a buffer that receives the selected text. The calling application must ensure that the buffer is large enough to hold the selected text.
Return Values
Returns the number of characters copied, not including the terminating null character.
SetSel()
Copy()
EM_GETSELTEXT可以通用。