From dfd45f0bd5339055ecd2b493afa9348201673694 Mon Sep 17 00:00:00 2001 From: Hummel009 Date: Fri, 12 Jan 2024 18:00:20 +0300 Subject: [PATCH] window style --- appC/src/Main.c | 47 ++++++------------- appCpp/src/Main.cpp | 47 ++++++------------- .../src/nativeMain/kotlin/hummel/Main.kt | 4 +- 3 files changed, 32 insertions(+), 66 deletions(-) diff --git a/appC/src/Main.c b/appC/src/Main.c index d753b02..e8c715d 100644 --- a/appC/src/Main.c +++ b/appC/src/Main.c @@ -181,22 +181,21 @@ static LRESULT wndProc(HWND window, UINT msg, WPARAM wParam, LPARAM lParam) int main() { char *className = "HummelCalculator"; + char *windowTitle = "WinAPI"; + + WNDCLASS windowClass; + windowClass.style = 0; + windowClass.lpfnWndProc = wndProc; + windowClass.cbClsExtra = 0; + windowClass.cbWndExtra = 0; + windowClass.hInstance = NULL; + windowClass.hIcon = NULL; + windowClass.hCursor = NULL; + windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + windowClass.lpszMenuName = NULL; + windowClass.lpszClassName = className; - WNDCLASSEX wc; - wc.cbSize = sizeof(WNDCLASSEX); - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = wndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = NULL; - wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wc.lpszMenuName = NULL; - wc.lpszClassName = className; - wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); - - RegisterClassExA(&wc); + RegisterClassA(&windowClass); int screenWidth = GetSystemMetrics(SM_CXSCREEN); int screenHeight = GetSystemMetrics(SM_CYSCREEN); @@ -207,23 +206,7 @@ int main() int windowX = max(0, (screenWidth - windowWidth) / 2); int windowY = max(0, (screenHeight - windowHeight) / 2); - char *windowTitle = "WinAPI"; - HWND window = CreateWindowExA( - WS_EX_CLIENTEDGE, - className, - windowTitle, - WS_OVERLAPPEDWINDOW, - windowX, - windowY, - windowWidth, - windowHeight, - NULL, - NULL, - NULL, - NULL); - - ShowWindow(window, SW_SHOW); - UpdateWindow(window); + CreateWindowExA(WS_EX_CLIENTEDGE, className, windowTitle, WS_VISIBLE | WS_OVERLAPPEDWINDOW, windowX, windowY, windowWidth, windowHeight, NULL, NULL, NULL, NULL); MSG msg; while (GetMessageA(&msg, NULL, 0u, 0u) != 0) diff --git a/appCpp/src/Main.cpp b/appCpp/src/Main.cpp index 542db89..19ad07f 100644 --- a/appCpp/src/Main.cpp +++ b/appCpp/src/Main.cpp @@ -178,22 +178,21 @@ static LRESULT wndProc(HWND window, UINT msg, WPARAM wParam, LPARAM lParam) int main() { string className = "HummelCalculator"; + string windowTitle = "WinAPI"; + + WNDCLASS windowClass; + windowClass.style = 0; + windowClass.lpfnWndProc = wndProc; + windowClass.cbClsExtra = 0; + windowClass.cbWndExtra = 0; + windowClass.hInstance = NULL; + windowClass.hIcon = NULL; + windowClass.hCursor = NULL; + windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + windowClass.lpszMenuName = NULL; + windowClass.lpszClassName = className.c_str(); - WNDCLASSEX wc; - wc.cbSize = sizeof(WNDCLASSEX); - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = wndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = NULL; - wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wc.lpszMenuName = NULL; - wc.lpszClassName = className.c_str(); - wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); - - RegisterClassExA(&wc); + RegisterClassA(&windowClass); int screenWidth = GetSystemMetrics(SM_CXSCREEN); int screenHeight = GetSystemMetrics(SM_CYSCREEN); @@ -204,23 +203,7 @@ int main() int windowX = max(0, (screenWidth - windowWidth) / 2); int windowY = max(0, (screenHeight - windowHeight) / 2); - string windowTitle = "WinAPI"; - HWND window = CreateWindowExA( - WS_EX_CLIENTEDGE, - className.c_str(), - windowTitle.c_str(), - WS_OVERLAPPEDWINDOW, - windowX, - windowY, - windowWidth, - windowHeight, - NULL, - NULL, - NULL, - NULL); - - ShowWindow(window, SW_SHOW); - UpdateWindow(window); + CreateWindowExA(WS_EX_CLIENTEDGE, className.c_str(), windowTitle.c_str(), WS_VISIBLE | WS_OVERLAPPEDWINDOW, windowX, windowY, windowWidth, windowHeight, NULL, NULL, NULL, NULL); MSG msg; while (GetMessageA(&msg, NULL, 0u, 0u) != 0) diff --git a/appKotlinNative/src/nativeMain/kotlin/hummel/Main.kt b/appKotlinNative/src/nativeMain/kotlin/hummel/Main.kt index e8e0cee..18bcaf2 100644 --- a/appKotlinNative/src/nativeMain/kotlin/hummel/Main.kt +++ b/appKotlinNative/src/nativeMain/kotlin/hummel/Main.kt @@ -66,10 +66,10 @@ fun main() { val windowY = max(0, (screenHeight - windowHeight) / 2) CreateWindowExW( - 0u, + WS_EX_CLIENTEDGE.toUInt(), className, windowTitle, - (WS_VISIBLE or WS_DLGFRAME or WS_SYSMENU).toUInt(), + (WS_VISIBLE or WS_OVERLAPPEDWINDOW).toUInt(), windowX, windowY, windowWidth,