Skip to content

Commit 8cb7c48

Browse files
these doesnt work, i just want to save it
1 parent 4a91f5b commit 8cb7c48

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
1313
set(CMAKE_BUILD_TYPE Release)
1414
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -funroll-loops -ffast-math")
1515

16+
if(win32)
17+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake") endif()
18+
1619
# Add subprojects
1720
add_subdirectory(basic)
1821
add_subdirectory(number_system)
1922
add_subdirectory(3D)
2023
add_subdirectory(image)
2124
add_subdirectory(discrete)
25+
add_subdirectory(win32)

win32/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
add_executable(win32app app.cxx)
2+
3+
# Supaya tidak muncul console (khusus untuk Win32 GUI)
4+
set_target_properties(win32app PROPERTIES
5+
WIN32_EXECUTABLE YES
6+
)
7+
8+
target_link_libraries(winn32app PRIVATE user32 gdi32 kernel32)

win32/app.cxx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <windows.h>
2+
3+
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
4+
LPARAM lParam) {
5+
switch (uMsg) {
6+
case WM_DESTROY:
7+
PostQuitMessage(0);
8+
return 0;
9+
}
10+
return DefWindowProc(hwnd, uMsg, wParam, lParam);
11+
}
12+
13+
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow) {
14+
const char CLASS_NAME[] = "MyWindowClass";
15+
16+
WNDCLASS wc = {};
17+
wc.lpfnWndProc = WindowProc;
18+
wc.hInstance = hInstance;
19+
wc.lpszClassName = CLASS_NAME;
20+
21+
RegisterClass(&wc);
22+
23+
HWND hwnd = CreateWindowEx(0, CLASS_NAME, "Hello, Win32 with CMake!",
24+
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
25+
800, 600, nullptr, nullptr, hInstance, nullptr);
26+
27+
if (!hwnd)
28+
return 0;
29+
30+
ShowWindow(hwnd, nCmdShow);
31+
32+
MSG msg = {};
33+
while (GetMessage(&msg, nullptr, 0, 0)) {
34+
TranslateMessage(&msg);
35+
DispatchMessage(&msg);
36+
}
37+
38+
return 0;
39+
}

win32/app.pdb

820 KB
Binary file not shown.

0 commit comments

Comments
 (0)