Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 팩터리 패턴
- 컴포지트 빌더
- 프로토타입 중복처리
- 싱글톤 패턴
- 프로토타입
- 팩터리
- 그루비 스타일 빌더
- 프로토타입 패턴
- 싱글톤
- 싱글턴 패턴
- 단순한 빌더
- 동적 데코레이터
- 빌더
- 디자인 패턴
- 데커레이터 패턴
- 브릿지 패턴
- 컴포지트 패턴
- 디자인패턴
- 데커레이터
- 컴포지트
- 함수형 팩터리
- 싱글턴
- 팩터리 메서드
- 모던C++디자인패턴
- 동적 데커레이터
- 흐름식 빌더
- 브릿지
- 빌더 패턴
- 내부 팩터리
- 추상 팩터리
Archives
- Today
- Total
GGym's Practice Notes
WinAPI 기본 구조 본문
#include<windows.h>
#define START_X 0
#define START_Y 0
#define WINSIZE_X 800
#define WINSIZE_Y 600
HINSTANCE g_hInst; // 인스턴스의 핸들 선언
LPCTSTR g_ClassName = TEXT("PARK"); // 클래스 이름
LPCTSTR g_WinName = TEXT("JUNE"); // 윈도우 이름
HWND g_hWnd; // 윈도우의 핸들
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPRevInstance, LPSTR lpszCmdParam, int nCmdShow) {
MSG Message;
WNDCLASS WndClass;
g_hInst = hInstance;
int nWidth, nHeight;
// 프레임의 사이즈를 더해줌.(상하좌우+캡션)
nWidth = WINSIZE_X + GetSystemMetrics(SM_CXFRAME) * 2;
nHeight = WINSIZE_Y + GetSystemMetrics(SM_CXFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION);
// 1 윈도우 클래스 초기화
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)WndProc; // 윈도우 프로시저 이름
WndClass.lpszClassName = g_ClassName; // 윈도우 클래스 이름
WndClass.lpszMenuName = NULL; // 메뉴의 이름
WndClass.style = CS_HREDRAW | CS_VREDRAW; // 윈도우의 스타일
// 2 클래스 등록
RegisterClass(&WndClass);
// 3 윈도우 생성
g_hWnd = CreateWindow(
g_ClassName, // 윈도우 클래스 문자열
g_WinName, // 타이틀 바에 나타날 문자열
WS_OVERLAPPEDWINDOW, // 윈도우의 형태 옵션 (OR 연산자 사용)
START_X, START_Y, // 윈도우 시작위치
nWidth, nHeight, // 윈도우 크기
NULL, // 부모 윈도우의 핸들
(HMENU)NULL, // 메뉴의 핸들
hInstance, // 인스턴스
NULL); // createStruct라는 구조체의 주소
// 4 윈도우를 화면에 보여줌
ShowWindow(g_hWnd, nCmdShow);
// 5 메세지 루프
while (GetMessage(&Message, 0, 0, 0)) {
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
HDC hdc;
PAINTSTRUCT ps;
switch (iMessage) {
case WM_TIMER: {
}break;
case WM_PAINT: {
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
}break;
case WM_LBUTTONDOWN: {
}break;
case WM_RBUTTONDOWN: {
}break;
case WM_KEYDOWN: {
switch (wParam) {
case VK_ESCAPE:
PostQuitMessage(0);
break;
}
}break;
case WM_DESTROY: {
PostQuitMessage(0);
return 0;
}
}
return(DefWindowProc(hWnd, iMessage, wParam, lParam));
}
'WinAPI' 카테고리의 다른 글
WinAPI에 OpenGL 쓰기 (0) | 2020.05.13 |
---|---|
GDI Object (0) | 2020.05.09 |
DC (Device Context) (0) | 2020.05.07 |
윈도우 창크기 조정 세팅 (AdjustWindowRect(), SetWindowPos) (0) | 2020.05.07 |