From 6614cc801e799faaa093423b52974c703c9ca2f5 Mon Sep 17 00:00:00 2001 From: Will Xyen Date: Thu, 4 Feb 2021 22:57:29 -0800 Subject: [PATCH] d3d9ex: fix framed and window sizes for IIDX --- src/main/d3d9exhook/d3d9ex.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/d3d9exhook/d3d9ex.c b/src/main/d3d9exhook/d3d9ex.c index b8a4d1d..ef6c87e 100644 --- a/src/main/d3d9exhook/d3d9ex.c +++ b/src/main/d3d9exhook/d3d9ex.c @@ -130,11 +130,16 @@ static HWND STDCALL my_CreateWindowExA( HINSTANCE hInstance, LPVOID lpParam) { - if (d3d9ex_windowed && d3d9ex_window_framed) { - /* use a different style */ - dwStyle |= WS_OVERLAPPEDWINDOW; - /* also show mouse cursor */ - ShowCursor(TRUE); + if (d3d9ex_windowed) { + if (d3d9ex_window_framed) { + /* use a different style */ + dwStyle |= WS_OVERLAPPEDWINDOW; + /* also show mouse cursor */ + ShowCursor(TRUE); + } else { + dwStyle = dwStyle & ~WS_OVERLAPPEDWINDOW; + ShowCursor(FALSE); + } } HWND hwnd = real_CreateWindowExA( @@ -389,6 +394,17 @@ static HRESULT STDCALL my_CreateDeviceEx( SetWindowLongPtr(hwnd, GWLP_WNDPROC, (uintptr_t) my_WndProc); } + if (d3d9ex_windowed) { + if (d3d9ex_window_width > 0 && d3d9ex_window_height > 0) { + // set window size + RECT rect; + GetWindowRect(hwnd, &rect); + + log_info("Calling SetWindowPos to fix window size: %dx%d", d3d9ex_window_width, d3d9ex_window_height); + SetWindowPos(hwnd, 0, rect.left, rect.top, d3d9ex_window_width, d3d9ex_window_height, 0); + } + } + return hr; }