본문 바로가기

프로그래밍/시스템

[윈도우 프로그래밍] WinMain 기본코딩

반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <windows.h>
#include <tchar.h>
LRESULT CALLBACK
WndProc(HWND hwnd,
 UINT iMsg, WPARAM wParam,
 LPARAM lParam);
int WINAPI _tWinMain(
 HINSTANCE hInstance,
 HINSTANCE hPrevInstance,
 LPTSTR lpCmdLine,
 int nCmdShow
)
{
 //1.윈도우를 보이게
 // 잘잘한 속성은 등록하고
 WNDCLASSEX wndClass;
 wndClass.cbClsExtra = 0;
 wndClass.cbSize = sizeof(wndClass);
 wndClass.cbWndExtra = 0;
 wndClass.hbrBackground = (HBRUSH)
  GetStockObject(WHITE_BRUSH);
 wndClass.hCursor = (HCURSOR)
  LoadCursor(NULL, IDC_ARROW);
 wndClass.hIcon = (HICON)
  LoadIcon(NULL, IDI_APPLICATION);
 wndClass.hIconSm = (HICON)
  LoadIcon(NULL, IDI_APPLICATION);
 wndClass.hInstance = hInstance;
 wndClass.lpfnWndProc = WndProc;
 wndClass.lpszClassName = _T("3장");
 wndClass.lpszMenuName = NULL;
 wndClass.style = CS_HREDRAW 
  | CS_VREDRAW;
 RegisterClassEx(&wndClass);
 //RegisterClassEx
 HWND hwnd;
 hwnd = CreateWindow
 (_T("3장"),
  _T("3장 내용 "),
  WS_OVERLAPPEDWINDOW,
  CW_USEDEFAULT,
  CW_USEDEFAULT,
  CW_USEDEFAULT,
  CW_USEDEFAULT,
  NULL,
  NULL,
  hInstance,
  NULL);
 ShowWindow(hwnd, nCmdShow);
 // CreateWindow
 // ShowWindow
 //2.메시지큐에서 메시지를 꺼내어
 MSG msg;
 while (GetMessage(&msg, NULL, 00))
 {
  TranslateMessage(&msg);
  DispatchMessage(&msg);
 }
 //번역하고 던진다.
 return 0;
}
LRESULT CALLBACK
WndProc(HWND hwnd,
 UINT iMsg, WPARAM wParam,
 LPARAM lParam)
{
 switch (iMsg)
 {
 case WM_CREATE:
  break;
  //x버튼을 누르는 순간 발생
 case WM_DESTROY:
  //WM_QUIT보냄
  PostQuitMessage(0);
  break;
 }
 return DefWindowProc(hwnd,
  iMsg, wParam, lParam);
}
cs


반응형