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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#include "resource.h"
#include <wchar.h>
#include <windows.h>
#include <commctrl.h>
// Global variables
static HINSTANCE hInst;
const wchar_t CLASS_NAME[] = L"ButchunkerWindow";
// Control IDs
#define IDC_CHECKBOX1 1009
#define IDC_CHECKBOX2 1008
#define IDC_CHECKBOX3 1007
#define IDC_BUTTON_CHECK 1006
// Function declarations
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PWSTR pCmdLine, int nCmdShow)
{
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_STANDARD_CLASSES | ICC_WIN95_CLASSES;
InitCommonControlsEx(&icex);
#ifdef _WIN32_WINNT_WINXP
#pragma comment(linker, \
"/manifestdependency:\"type='win32' \
name='Microsoft.Windows.Common-Controls' \
version='6.0.0.0' \
processorArchitecture='*' \
publicKeyToken='6595b64144ccf1df' \
language='*'\"" \
)
#endif
(void)hPrevInstance; // Unused parameter
(void)pCmdLine; // Unused parameter
hInst = hInstance;
// Register window class
WNDCLASSW windowClass = {0};
windowClass.lpfnWndProc = WindowProc;
windowClass.hInstance = hInstance;
windowClass.lpszClassName = CLASS_NAME;
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
windowClass.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU);
if (!RegisterClassW(&windowClass)) {
MessageBoxW(NULL, L"Window class registration failed!", L"Error", MB_ICONERROR);
return 0;
}
const int WINDOW_WIDTH = 800;
const int WINDOW_HEIGHT = 600;
// Create window
HWND hwnd = CreateWindowExW(
0, // Extended window style
CLASS_NAME, // Window class name
L"Butchunker - File Chunking Tool", // Window title
WS_OVERLAPPEDWINDOW, // Window style
CW_USEDEFAULT, CW_USEDEFAULT, // Position
WINDOW_WIDTH, WINDOW_HEIGHT, // Size
NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional data
);
if (hwnd == NULL) {
MessageBoxW(NULL, L"Window creation failed!", L"Error", MB_ICONERROR);
return 0;
}
// Show window
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
// Message loop
MSG msg = {0};
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
// Window procedure function
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_COMMAND: {
int wmId = LOWORD(wParam);
switch (wmId) {
case IDM_EXIT:
DestroyWindow(hwnd);
break;
case IDM_ABOUT:
MessageBoxW(hwnd, L"Butchunker - File Chunking Tool\nVersion 1.0.0", L"About", MB_OK);
break;
default:
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
break;
}
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
return 0;
}
|