#include <Windows.h>
#include <Math.h>
// LRESULT == 32bit 정수형
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam , LPARAM lParam)
{
HDC hdc; // handle device context
PAINTSTRUCT ps;
char str[256] = "Hello API";
int x,y,kd;
double r;
int h = 50;
switch(message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd,&ps); // GetDC
OutputDebugString("WM_PAINT");
// rectangle
Rectangle(hdc,100,100,200,200);
// tri angle
MoveToEx(hdc,350,100,NULL);
LineTo(hdc,300,200);
LineTo(hdc,400,200);
LineTo(hdc,350,100);
// ellipse
Ellipse(hdc,500,100,600,200);
// star
MoveToEx(hdc,250,350,NULL);
LineTo(hdc,150,650);
LineTo(hdc,400,450);
LineTo(hdc,100,450);
LineTo(hdc,350,650);
LineTo(hdc,250,350);
//hexagon
MoveToEx(hdc,700,350,NULL);
LineTo(hdc,600,400);
LineTo(hdc,600,500);
LineTo(hdc,700,550);
LineTo(hdc,800,500);
LineTo(hdc,800,400);
LineTo(hdc,700,350);
// radian
for(int i = 0; i< 10; i++)
{
kd = 10 * i + 90;
r = kd *3.141592/180.0;
x = (int)(cos(r)*h);
y = (int)(sin(r)*h);
MoveToEx(hdc,100 + x, 700 + y,NULL);
LineTo(hdc, 100 - x, 700 - y);
}
EndPaint(hWnd,&ps); // ReleaseDC
break;
case WM_DESTROY:
OutputDebugString("WM_DESTROY");
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd,message,wParam,lParam);
}
'Study > C / C++' 카테고리의 다른 글
API 1942 따라 만들기 - 중간 - (0) | 2014.09.22 |
---|---|
API 비행기 출력 소스 (0) | 2014.09.12 |
Cpp / 스택을 이용한 주소록 (0) | 2014.09.05 |
C언어 링크드 리스트를 이용한 학생 정보 저장 (0) | 2014.09.04 |
Black Jack ver.2 (0) | 2014.09.04 |