간단하게 CDC::Ellipse() 함수를 이용해서
윈도우에 랜덤한 타원을 출력시키는 프로그램.

CBrush와 CPen으로 브러시와 펜을 생성및 초기화 하고
SelectObject 함수로 DC에 선택한다.




#include <afxwin.h>

class CEllipseApp: public CWinApp
{
public:

 virtual BOOL InitInstance();

};

CEllipseApp theApp;

class CMainWnd : public CFrameWnd
{

public:

 CMainWnd();
 ~CMainWnd();

 afx_msg void OnTimer(UINT nIDEvent);

 DECLARE_MESSAGE_MAP();
};

void CMainWnd::OnTimer(UINT nIDEVENT)
{

 CClientDC dc(this);

 CRect rect;
 GetClientRect(rect);

 CBrush brush(RGB(rand()%255,rand()%255,rand()&255));
 dc.SelectObject(&brush);
 CPen pen(PS_SOLID,rand()%5,RGB(0,0,0));
 dc.SelectObject(&pen);

 dc.Ellipse(rand()%rect.Width(),rand()%rect.Height(),rand()%rect.Width(),rand()%rect.Height());

}

BEGIN_MESSAGE_MAP(CMainWnd,CFrameWnd)
 ON_WM_TIMER()
END_MESSAGE_MAP()

BOOL CEllipseApp::InitInstance()
{
 m_pMainWnd = new CMainWnd();
 m_pMainWnd->ShowWindow(m_nCmdShow);
 m_pMainWnd->UpdateWindow();
 return TRUE;

}

CMainWnd::CMainWnd()
{

 Create(NULL,L"Ellipse");
 SetTimer(10,100,NULL);

}

CMainWnd::~CMainWnd()
{
 KillTimer(10);
}


Posted by 후니 유

댓글을 달아주세요:: 스팸은 정중히 사절합니다.


BLOG main image
Cr4cK th3 W0Rld by 후니 유

1,214,104


Today : 141
Yesterday : 177
hit counters

카테고리

전체보기 (802)
Etc (246)
Hacked Brain (280)
My Project (32)
데일리 (22)
운영체제 (31)
프로그래밍 (92)
Securities (27)