본문 바로가기
Code review

[WinApi]apiStart

by cafrisun 2009. 5. 27.
 

 apiStart.cpp from http://www.winapi.co.kr 


01: #include <windows.h>
02: 
03: LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
04: HINSTANCE g_hInst;
05: LPSTR lpszClass="Class";
06: 
07: int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance
08:                                          ,LPSTR lpszCmdParam,int nCmdShow)
09: {
10:         HWND hWnd;
11:         MSG Message;
12:         WNDCLASS WndClass;
13:         g_hInst=hInstance;
14:         
15:         WndClass.cbClsExtra=0;
16:         WndClass.cbWndExtra=0;
17:         WndClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
18:         WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
19:         WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
20:         WndClass.hInstance=hInstance;
21:         WndClass.lpfnWndProc=(WNDPROC)WndProc;
22:         WndClass.lpszClassName=lpszClass;
23:         WndClass.lpszMenuName=NULL;
24:         WndClass.style=CS_HREDRAW | CS_VREDRAW;
25:         RegisterClass(&WndClass);
26:         
27:         hWnd=CreateWindow(lpszClass,lpszClass,WS_OVERLAPPEDWINDOW,
28:                 CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
29:                 NULL,(HMENU)NULL,hInstance,NULL);
30:         ShowWindow(hWnd,nCmdShow);
31:         
32:         while(GetMessage(&Message,0,0,0)) {
33:                 TranslateMessage(&Message);
34:                 DispatchMessage(&Message);
35:         }
36:         return Message.wParam;
37: }
38: 
39: LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
40: {
41:         HDC hdc;
42:         PAINTSTRUCT ps;
43:         switch(iMessage) {
44:         case WM_CREATE:
45:                 return 0;
46:         case WM_PAINT:
47:                 hdc=BeginPaint(hWnd, &ps);
48:                 EndPaint(hWnd, &ps);
49:                 return 0;
50:         case WM_DESTROY:
51:                 PostQuitMessage(0);
52:                 return 0;
53:         }
54:         return(DefWindowProc(hWnd,iMessage,wParam,lParam));
55: }

반응형

'Code review' 카테고리의 다른 글

[C]파일 사이즈 구하기  (3) 2009.05.27
[C]File merge  (0) 2009.05.27
Linked List Sample  (2) 2009.05.27