-
MFC question...
I have a problem to write an MFC application that will display whatever the user types in the client area. Also I need to restore (repaint) everything when user minimize the window.
Right now I am using the code from the book that allows user to enter one char and to restore the same one but I dont know how to that for more lines. New line should start when user press enter.
Code:
// Process a WM_CHAR message.
afx_msg void CMainWin::OnChar(UINT ch,
UINT count, UINT flags)
{
CClientDC dc(this);
dc.TextOut(1, 1, " ", 3); // erase previous char
wsprintf(str, "%c", ch);
dc.TextOut(1, 1, str, strlen(str));
}
// Process a WM_PAINT message.
afx_msg void CMainWin::OnPaint()
{
// If we use CClientDC instead we will have a LOT of paint messages.
CPaintDC dc(this);
// this line redisplays the last character
dc.TextOut(1, 1, str, strlen(str));
}
this is what i'm using so far (copy/paste from the book)
everything will help
Thanks
-
Instead of using a char* you should change it to using CString (MFC) or string (STL) that way in the OnChar() function you could do variable += ch to add the char on the end of the string.