![]() ![]() 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 You can make it totally sure that the :: GetWindowText wasn't called by. By using GetDlgItem (IDCEDITFLEK) you should get the original and so the correct value. ![]() HRESULT hr = StringCchCopyExW( pDest, cchDest, text.GetString(), &pDestEnd, nullptr, 0 ) As Zoppo explained, the customized edit control has a own GetWindowText which retrieves the value from a member variable rather than from the screen. cchDest defines the maximum number of characters to be copied, including the terminating null character. 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. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |