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 80 81 82
|
#include <windows.h>
#include <string>
#include <fstream>
#include <winver.h>
#include "res.h"
using namespace std;
LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
HINSTANCE hInst;
HICON main_icon;
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow) {
MSG msg;
WNDCLASS wc;
HWND hwnd = NULL;
hInst = hThisInstance;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = CreateSolidBrush(RGB(192, 192, 192));
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = hThisInstance;
wc.lpfnWndProc = WinProc;
wc.lpszClassName = "Window";
wc.lpszMenuName = NULL;
wc.style = CS_HREDRAW | CS_VREDRAW;
if (!RegisterClass(&wc)) {
MessageBox(NULL, "Error registering class", "ERROR", MB_OK);
return 0;
}
hwnd = CreateWindow("Window",
"HW2BDEd v1.0.0",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
640,
400,
NULL,
NULL,
hThisInstance,
NULL);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_CREATE: {
main_icon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_WINDOWICON));
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)main_icon);
} break;
case WM_DESTROY: {
PostQuitMessage(0);
return 0;
} break;
case WM_CLOSE: {
DestroyWindow(hwnd);
} break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
| |