Use own GetWindowRect instead of WinAPI's

This commit is contained in:
Inori 2019-08-08 09:40:50 -04:00 committed by Inori
parent 3a00328594
commit d08c07b42a
3 changed files with 22 additions and 0 deletions

View file

@ -48,6 +48,7 @@ MiniFFI_GetFunctionHandle(void *lib, const char *func)
CAPTURE(GetCursorPos); CAPTURE(GetCursorPos);
CAPTURE(ScreenToClient); CAPTURE(ScreenToClient);
CAPTURE(SetWindowPos); CAPTURE(SetWindowPos);
CAPTURE(GetWindowRect);
CAPTURE(RegisterHotKey); CAPTURE(RegisterHotKey);
#endif #endif
return SDL_LoadFunction(lib, func); return SDL_LoadFunction(lib, func);

View file

@ -115,6 +115,24 @@ MKXP_SetWindowPos(HWND hWnd,
return true; return true;
} }
// Games that use this to resize the window won't center
// themselves, but it's better than having the window sent
// so far into the corner that you can't even grab onto
// the title bar
BOOL __stdcall
MKXP_GetWindowRect(HWND hWnd, LPRECT lpRect)
{
int cur_x, cur_y, cur_w, cur_h;
SDL_GetWindowPosition(shState->sdlWindow(), &cur_x, &cur_y);
SDL_GetWindowSize(shState->sdlWindow(), &cur_w, &cur_h);
lpRect->left = cur_x;
lpRect->right = cur_x + cur_w + 1;
lpRect->top = cur_y;
lpRect->bottom = cur_y + cur_h + 1;
return true;
}
BOOL __stdcall BOOL __stdcall
MKXP_RegisterHotKey(HWND hWnd, MKXP_RegisterHotKey(HWND hWnd,
int id, int id,

View file

@ -63,6 +63,9 @@ MKXP_SetWindowPos(HWND hWnd,
int cy, int cy,
UINT uFlags); UINT uFlags);
BOOL __stdcall
MKXP_GetWindowRect(HWND hWnd, LPRECT lpRect);
BOOL __stdcall BOOL __stdcall
MKXP_RegisterHotKey(HWND hWnd, MKXP_RegisterHotKey(HWND hWnd,
int id, int id,