Return actual window handle with FindWindowEx

This commit is contained in:
Inori 2019-08-06 23:40:29 -04:00
parent 8b7c882b7c
commit ff01f700de
2 changed files with 11 additions and 9 deletions

View file

@ -48,13 +48,17 @@ DWORD __stdcall
MKXP_GetWindowThreadProcessId(HWND hWnd, LPDWORD lpdwProcessId) MKXP_GetWindowThreadProcessId(HWND hWnd, LPDWORD lpdwProcessId)
NOP_VAL(DUMMY_VAL) NOP_VAL(DUMMY_VAL)
DWORD __stdcall HWND __stdcall
MKXP_FindWindowEx(HWND hWnd, MKXP_FindWindowEx(HWND hWnd,
HWND hWndChildAfter, HWND hWndChildAfter,
LPCSTR lpszClass, LPCSTR lpszClass,
LPCSTR lpszWindow LPCSTR lpszWindow
) )
NOP_VAL(DUMMY_VAL) {
SDL_SysWMinfo wm;
SDL_GetWindowWMInfo(shState->sdlWindow(), &wm);
return wm.info.win.window;
}
DWORD __stdcall DWORD __stdcall
MKXP_GetForegroundWindow(void) MKXP_GetForegroundWindow(void)
@ -76,9 +80,9 @@ MKXP_GetClientRect(HWND hWnd, LPRECT lpRect)
} }
// You would think that you could just call GetCursorPos
// FIXME: Mouse stuff doesn't work right now, // and ScreenToClient with the window handle and lppoint
// but at least it's not causing any Ruby exceptions // and be fine, but nope
BOOL __stdcall BOOL __stdcall
MKXP_GetCursorPos(LPPOINT lpPoint) MKXP_GetCursorPos(LPPOINT lpPoint)
{ {
@ -106,9 +110,7 @@ MKXP_SetWindowPos(HWND hWnd,
// SetWindowPos, but it still needs to be called // SetWindowPos, but it still needs to be called
// because Win32API.restoreScreen is picky about its // because Win32API.restoreScreen is picky about its
// metrics // metrics
SDL_SysWMinfo wm; SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
SDL_GetWindowWMInfo(shState->sdlWindow(), &wm);
SetWindowPos(wm.info.win.window, hWndInsertAfter, X, Y, cx, cy, uFlags);
SDL_SetWindowPosition(shState->sdlWindow(), X, Y); SDL_SetWindowPosition(shState->sdlWindow(), X, Y);
return true; return true;
} }

View file

@ -35,7 +35,7 @@ MKXP_GetCurrentThreadId(void);
DWORD __stdcall DWORD __stdcall
MKXP_GetWindowThreadProcessId(HWND hWnd, LPDWORD lpdwProcessId); MKXP_GetWindowThreadProcessId(HWND hWnd, LPDWORD lpdwProcessId);
DWORD __stdcall HWND __stdcall
MKXP_FindWindowEx(HWND hWnd, MKXP_FindWindowEx(HWND hWnd,
HWND hWndChildAfter, HWND hWndChildAfter,
LPCSTR lpszClass, LPCSTR lpszClass,