mirror of
https://gitea.tendokyu.moe/Hay1tsme/segatools.git
synced 2024-11-25 01:40:11 +01:00
hooklib/gfx.c: Add option to frame the d3d window
This commit is contained in:
parent
7c721aa1f8
commit
b270eaf1c6
@ -23,6 +23,7 @@ static HRESULT STDMETHODCALLTYPE my_CreateDevice(
|
||||
IDirect3DDevice9 **pdev);
|
||||
static IDirect3D9 * WINAPI my_Direct3DCreate9(UINT sdk_ver);
|
||||
static IDirect3D9 * (WINAPI *next_Direct3DCreate9)(UINT sdk_ver);
|
||||
static HRESULT gfx_frame_window(HWND hwnd);
|
||||
|
||||
static struct gfx_config gfx_config;
|
||||
|
||||
@ -106,5 +107,72 @@ static HRESULT STDMETHODCALLTYPE my_CreateDevice(
|
||||
pp->FullScreen_RefreshRateInHz = 0;
|
||||
}
|
||||
|
||||
if (gfx_config.framed) {
|
||||
gfx_frame_window(hwnd);
|
||||
}
|
||||
|
||||
return IDirect3D9_CreateDevice(real, adapter, type, hwnd, flags, pp, pdev);
|
||||
}
|
||||
|
||||
static HRESULT gfx_frame_window(HWND hwnd)
|
||||
{
|
||||
HRESULT hr;
|
||||
DWORD error;
|
||||
LONG style;
|
||||
RECT rect;
|
||||
BOOL ok;
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
style = GetWindowLongW(hwnd, GWL_STYLE);
|
||||
error = GetLastError();
|
||||
|
||||
if (error != ERROR_SUCCESS) {
|
||||
hr = HRESULT_FROM_WIN32(error);
|
||||
dprintf("Gfx: GetWindowLongPtrW(%p, GWL_STYLE) failed: %x\n",
|
||||
hwnd,
|
||||
(int) hr);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
ok = GetClientRect(hwnd, &rect);
|
||||
|
||||
if (!ok) {
|
||||
hr = HRESULT_FROM_WIN32(GetLastError());
|
||||
dprintf("Gfx: GetClientRect(%p) failed: %x\n", hwnd, (int) hr);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
style |= WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;
|
||||
ok = AdjustWindowRect(&rect, style, FALSE);
|
||||
|
||||
if (!ok) {
|
||||
/* come on... */
|
||||
hr = HRESULT_FROM_WIN32(GetLastError());
|
||||
dprintf("Gfx: AdjustWindowRect failed: %x\n", (int) hr);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/* This... always seems to set an error, even though it works? idk */
|
||||
SetWindowLongW(hwnd, GWL_STYLE, style);
|
||||
|
||||
ok = SetWindowPos(
|
||||
hwnd,
|
||||
HWND_TOP,
|
||||
rect.left,
|
||||
rect.top,
|
||||
rect.right - rect.left,
|
||||
rect.bottom - rect.top,
|
||||
SWP_FRAMECHANGED | SWP_NOMOVE);
|
||||
|
||||
if (!ok) {
|
||||
hr = HRESULT_FROM_WIN32(GetLastError());
|
||||
dprintf("Gfx: SetWindowPos(%p) failed: %x\n", hwnd, (int) hr);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user