Skip to content

Commit

Permalink
window style
Browse files Browse the repository at this point in the history
  • Loading branch information
Hummel009 committed Jan 12, 2024
1 parent 02fc0bd commit dfd45f0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 66 deletions.
47 changes: 15 additions & 32 deletions appC/src/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down
47 changes: 15 additions & 32 deletions appCpp/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions appKotlinNative/src/nativeMain/kotlin/hummel/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit dfd45f0

Please sign in to comment.