LuvSea
직선, 원, 사각형 그리기 본문
#include<windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
HINSTANCE g_hInst;
LPCTSTR lpszClass=TEXT("first");
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevlnstance, LPSTR lpszCmdParam, int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
g_hInst=hInstance;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WndProc;
WndClass.lpszClassName=lpszClass;
WndClass.lpszMenuName=NULL;
WndClass.style=CS_HREDRAW|CS_VREDRAW;
RegisterClass(&WndClass);
hWnd=CreateWindow(lpszClass,lpszClass,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,
(HMENU)NULL,hInstance,NULL);
ShowWindow(hWnd,nCmdShow);
while(GetMessage(&Message,NULL,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return (int)Message.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM WParam,LPARAM IParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch(iMessage)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
hdc = BeginPaint(hWnd,&ps);
SetPixel(hdc,10,10,RGB(255,0,0));
Rectangle(hdc,50,100,150,200); //사각형 x1 50 x2 150 y1 100 y2 200
Ellipse(hdc,50,100,150,200); // 원 x-r y-r x+r y+r
MoveToEx(hdc,150,200,NULL); // 직선 그리기x1 y1
LineTo(hdc,50,100); // x2 y2
MoveToEx(hdc,150,100,NULL);
LineTo(hdc,50,200);
MoveToEx(hdc,50,100,NULL);
LineTo(hdc,100,50);
MoveToEx(hdc,100,50,NULL);
LineTo(hdc,150,100);
EndPaint(hWnd,&ps);
return 0;
}
return(DefWindowProc(hWnd,iMessage,WParam,IParam));
}
/*반원 그리기
case WM_PAINT:
hdc = BeginPaint(hWnd,&ps);
SetPixel(hdc,10,10,RGB(255,0,0));
Ellipse(hdc,200,200,300,300); // 원 x-r y-r x+r y+r
MoveToEx(hdc,250,300,NULL); // 직선 그리기x1 y1
LineTo(hdc,250,500); // x2 y2
MoveToEx(hdc,250,350,NULL); // 직선 그리기x1 y1
LineTo(hdc,150,200); // x2 y2
MoveToEx(hdc,250,350,NULL); // 직선 그리기x1 y1
LineTo(hdc,350,200); // x2 y2
MoveToEx(hdc,250,500,NULL); // 직선 그리기x1 y1
LineTo(hdc,150,650); // x2 y2
MoveToEx(hdc,250,500,NULL); // 직선 그리기x1 y1
LineTo(hdc,350,650); // x2 y2
Arc(hdc,80,80,400,400,400,80,80,80);
Arc(hdc,80,40,400,360,400,40,80,40);
EndPaint(hWnd,&ps);
return 0;
*/
'sTudy' 카테고리의 다른 글
키 입력과 무효 영역 (0) | 2009.07.06 |
---|---|
Message Box (0) | 2009.07.06 |
API 기본 출력 소스 (0) | 2009.07.06 |
텍스트형 LCD 모듈 응용 프로그램을 이용한 사용자 정의문자 출력 (1) | 2009.06.04 |
ARM7TDMI AT91SAM7S256의 H-jtag 설치 및 사용 (0) | 2009.06.01 |