

The return value is the number of characters copied, not including the terminating null character. If( SUCCEEDED( hr ) || hr = STRSAFE_E_INSUFFICIENT_BUFFER ) If our text is greater in length than cchDest - 1, the function will truncate the text and HRESULT hr = StringCchCopyExW( pDest, cchDest, text.GetString(), &pDestEnd, nullptr, 0 ) A remote application interface (RAPI) version of this function exists, and it is called CeGetWindowText (RAPI). If the specified window is a control, the text of the control is copied. However, GetWindowText cannot retrieve the text of a control in another application. cchDest defines the maximum number of characters to be copied, including the terminating null character. GetWindowText (Windows CE 5.0) This function copies the text of the specified window's title bar if it has one into a buffer. Copies the text of the specified window's title bar (if it has one) into a buffer. Using StringCchCopyExW() to make sure that we don't write outside of the bounds of the pDest buffer. int CMyEdit::OnGetText( int cchDest, LPWSTR pDest ) Now comes the actual handler for WM_GETTEXT which copies the transformed text to the output buffer. For simplicity I just enclose the text in dashes. Anything would be possible here, including the example of converting between hex and dec.

The following method gets the original window text and transforms it. Len = DefWindowProcW( WM_GETTEXT, len + 1, reinterpret_cast( text.GetBuffer( len ) ) ) WPARAM = len + 1 because the length must include the null terminator. LRESULT len = DefWindowProcW( WM_GETTEXTLENGTH, 0, 0 )

For this we can directly call the default window procedure which is named DefWindowProc: CStringW CMyEdit::GetTextInternal() Add message map entries for WM_GETTEXT and WM_GETTEXTLENGTH to your derived CEdit class: BEGIN_MESSAGE_MAP( CMyEdit, CEdit )Īs we are overriding these messages we need a method of getting the original text of the edit control without going into endless recursion.
