add API for getting/setting window size

bahahahaaa
This commit is contained in:
Arisotura 2019-05-23 22:50:46 +02:00
parent 3915b8cb4e
commit e5236f0cde
3 changed files with 20 additions and 0 deletions

View File

@ -108,6 +108,8 @@ typedef struct uiWindow uiWindow;
#define uiWindow(this) ((uiWindow *) (this)) #define uiWindow(this) ((uiWindow *) (this))
_UI_EXTERN char *uiWindowTitle(uiWindow *w); _UI_EXTERN char *uiWindowTitle(uiWindow *w);
_UI_EXTERN void uiWindowSetTitle(uiWindow *w, const char *title); _UI_EXTERN void uiWindowSetTitle(uiWindow *w, const char *title);
_UI_EXTERN void uiWindowPosition(uiWindow *w, int *x, int *y);
_UI_EXTERN void uiWindowSetPosition(uiWindow *w, int x, int y);
_UI_EXTERN void uiWindowContentSize(uiWindow *w, int *width, int *height); _UI_EXTERN void uiWindowContentSize(uiWindow *w, int *width, int *height);
_UI_EXTERN void uiWindowSetContentSize(uiWindow *w, int width, int height); _UI_EXTERN void uiWindowSetContentSize(uiWindow *w, int width, int height);
_UI_EXTERN int uiWindowMinimized(uiWindow *w); _UI_EXTERN int uiWindowMinimized(uiWindow *w);

View File

@ -363,6 +363,21 @@ static void windowMonitorRect(HWND hwnd, RECT *r)
*r = mi.rcMonitor; *r = mi.rcMonitor;
} }
void uiWindowPosition(uiWindow *w, int *x, int *y)
{
RECT rect;
if (GetWindowRect(w->hwnd, &rect) == 0)
logLastError(L"error getting window position");
*x = rect.left;
*y = rect.top;
}
void uiWindowSetPosition(uiWindow *w, int x, int y)
{
if (SetWindowPos(w->hwnd, NULL, x, y, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER) == 0)
logLastError(L"error moving window");
}
void uiWindowContentSize(uiWindow *w, int *width, int *height) void uiWindowContentSize(uiWindow *w, int *width, int *height)
{ {
RECT r; RECT r;

View File

@ -1859,9 +1859,12 @@ void OnOpenVideoSettings(uiMenuItem* item, uiWindow* window, void* blarg)
EmuRunning = 3; EmuRunning = 3;
while (EmuStatus != 3); while (EmuStatus != 3);
int winX, winY;
uiWindowPosition(MainWindow, &winX, &winY);
uiControlDestroy(uiControl(window)); uiControlDestroy(uiControl(window));
zarg(); zarg();
uiWindowSetPosition(MainWindow, winX, winY);
EmuRunning = zerp; EmuRunning = zerp;
} }