Re: Back to CDialog from child window ?
RAN wrote:
Hi RAN,
void CTextEntry::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
if(nChar == VK_RETURN)
{
GetWindowText(t_TextEntry.o_TextEntryStr);
SetWindowText("");
if(t_TextEntry.o_TextEntryStr.IsEmpty () == FALSE)
::SendMessage(hWnd,UDM_ONTEXTENTRY_COMPLETED,1,
(long)&t_TextEntry);
Here you are passing a pointer to the object.
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
and:
LRESULT CClientDlg::OnTextEntryCompleted(WPARAM wParam, LPARAM lParam)
{
if(wParam == 1)
{
t_TextEntry = (TEXTENTRY&) lParam;
Here you are casting the pointer to a reference. Do:
t_TextEntry = *(TEXTENTRY*) lParam;
or more officially:
t_TextEntry= *reinterpret_cast<TEXTENTRY*>( lParam );
And by:
TEXTENTRY& t_TextEntry= *reinterpret_cast<TEXTENTRY*>( lParam );
You avoid a copy constructor;
If you want a reference. But I would keep it a pointer.
And you can:
ASSERT_NULL_OR_POINTER( ... )
Best, Dan.
// o_ChatTextEntry.InsertText (LPCSTR(t_TextEntry.o_TextEntryStr));
}
return 0;
}
the contents of TEXTENTRY is garbage !? If i create a PTEXTENTRY
dynamically the contents is ok ? Why ?