U E D R , A S I H C RSS

5�용C++스터디/API�서MFC로

MFC란???

  • Microsoft Foundation Class library
  • 윈ë�„우즈 프로그래ë°�ì�„ 보다 ê°�체지향ì �으로 하기 위하여 MSì—�서 만든 í�´ëž˜ìФ ë�¼ì�´ë¸ŒëŸ¬ë¦¬.

윈�우즈 프로그래�� 필요한 요소들� �래스로 �장

  • ì—�플리케ì�´ì…˜ - CWinApp
  • 윈ë�„ìš° - CWnd
  • 다ì�´ì–¼ë¡œê·¸ë°•스 - CDialog
  • DC - CDC
  • 펜 - CPen
  • 브í�¼ì‰¬ - CBrush
  • 비트맵 - CBitmap
  • 메뉴 - CMenu
  • 버튼 - CButton
  • ì—�디트박스 - CEdit

매�로와 가�함수를 �용한 메시지 처리

~cpp 
BEGIN_MESSAGE_MAP(CApplicationView, CView)
	//{{AFX_MSG_MAP(CApplicationView)
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_KEYDOWN()
	ON_WM_KEYUP()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
~cpp 
class CApplicationView : public CView
{
	.
	.
	.

// Generated message map functions
protected:
	//{{AFX_MSG(CApplicationView)
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
	//}}AFX_MSG
	...
};
~cpp 
/////////////////////////////////////////////////////////////////////////////
// CApplicationView message handlers

void CApplicationView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	
	CView::OnLButtonDown(nFlags, point);
}

void CApplicationView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	
	CView::OnLButtonUp(nFlags, point);
}

void CApplicationView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	
	CView::OnKeyDown(nChar, nRepCnt, nFlags);
}

void CApplicationView::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	
	CView::OnKeyUp(nChar, nRepCnt, nFlags);
}

�종 툴과� 통합

  • AppWizard - ì—�플리케ì�´ì…˜ì�˜ 기본 구조를 ìž�ë�™ìœ¼ë¡œ ìƒ�성해주는 툴.
  • ClassWizard - í�´ëž˜ìФì�˜ 함수 오버ë�¼ì�´ë”©, 메시지 처리 등 복잡한 과정ì�„ ìž�ë�™ìœ¼ë¡œ 처리해주는 툴.
  • WizardBar - ClassWizardì�˜ ì•소íŒ�으로 사용하기 ë�”ìš± 쉽고 편함.

Document/View 아키��

MFC로 만든 SDI �플리케�션� 구조

MFC로 만든 MDI �플리케�션� 구조

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:17
Processing time 0.0054 sec