2009. 8. 27. 15:40 Programming/MFC

Project 생성시

  • 클래스 이름 변경
    • CMDIExView -> CKeyView
    • CMDIExDoc -> CKeyDoc

KeyDoc.h

class CKeyDoc : public CDocument
public:
	CString m_String;

WM_CHAR

void CKeyView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	CKeyDoc *pDoc = GetDocument();
	pDoc->m_String += (char)nChar;
	Invalidate(FALSE);
}

OnDraw

void CKeyView::OnDraw(CDC* pDC)
{
	CKeyDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;
 
	// TODO: 여기에 원시 데이터에 대한 그리기 코드를 추가합니다.
	pDC->TextOut(0, 0, pDoc->m_String, pDoc->m_String.GetLength());
}

WM_CHAR 수정

void CKeyView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	CKeyDoc *pDoc = GetDocument();
	pDoc->m_String += (char)nChar;
	Invalidate(FALSE);
	pDoc->UpdateAllViews(this);
}

posted by 부풍