요즘 윈도우폼 잘 안쓰지만 일부는 기본구성이라서 써야합니다
* 종료는 기본적으로 프로젝트에 맞게끔 추가 구현하여 사용
ex] 전역 키보드후킹을 통해서 핫키
ex] 트레이아이콘 팝업컨텍스트메뉴
ex] 윈도우 최신 유니버셜앱과 소켓통신
main.h 헤더 소스코드
#include <Windows.h>
LRESULT __stdcall WindowProc(
_In_ HWND hwnd,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
typedef struct Form {
HWND window;
WNDCLASSEXW wnd;
} Form;
typedef struct Helper {
static wchar_t* name;
static wchar_t* Message;
} Helper;
소스코드
#include "main.h"
Form FormMain;
wchar_t* Helper::name = L"fnHelper";
wchar_t* Helper::Message = L"Message";
int __stdcall WinMain(
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
) {
WNDCLASSEXW wc = {
sizeof(WNDCLASSEXW),
CS_GLOBALCLASS,
(WNDPROC)WindowProc,
0,
0,
hInstance,
LoadIcon((HINSTANCE)NULL, IDI_APPLICATION),
LoadCursor((HINSTANCE)NULL, IDC_APPSTARTING),
(HBRUSH)COLOR_WINDOW,
L"",
Helper::Message,
NULL
};
if (RegisterClassExW(&wc) != 0) return -1;
HWND hWin = CreateWindowExW(0,Helper::Message, Helper::name, WS_OVERLAPPED,0,0,0,0,NULL,NULL,hInstance,NULL);
if (hWin == 0) return -1;
FormMain = {hWin,wc};
MSG m;
int rt;
while (rt = GetMessage(&m, NULL, 0, 0), rt != 0) {
TranslateMessage(&m);
DispatchMessageW(&m);
}
return 0;
}
LRESULT __stdcall WindowProc(
_In_ HWND hwnd,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
) {
return 0;
}