X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=instimg;a=blobdiff_plain;f=src%2Fwidgets.c;h=9ae4c1ed6bbdcb25c6c7553f576aecdab0b7b7b9;hp=1b97637dd054564d3629109a30bfbc1f918dad62;hb=c81bf22901960cf05babbb157272d784f47a18f6;hpb=6903798ce9d75f2918ea2e160cd368033d06a9e7 diff --git a/src/widgets.c b/src/widgets.c index 1b97637..9ae4c1e 100644 --- a/src/widgets.c +++ b/src/widgets.c @@ -6,6 +6,8 @@ #include #include "widgets.h" +#define WIN_STYLE WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME + struct wgt_window { HWND handle; struct wgt_rect rect; @@ -98,8 +100,14 @@ struct wgt_window *wgt_window(const char *title, int width, int height) return 0; } - if(!(win->handle = CreateWindow(win->cname, title, WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME, - CW_USEDEFAULT, CW_USEDEFAULT, width, height, 0, 0, hinst, 0))) { + rect.left = rect.top = 0; + rect.right = width; + rect.bottom = height; + AdjustWindowRect(&rect, WIN_STYLE, FALSE); + + if(!(win->handle = CreateWindow(win->cname, title, WIN_STYLE, CW_USEDEFAULT, + CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, + 0, 0, hinst, 0))) { fprintf(stderr, "wgt_create_window: failed to create window\n"); UnregisterClass(title, hinst); return 0; @@ -154,9 +162,20 @@ void wgt_destroy_widget(struct wgt_widget *w) void wgt_resize_window(struct wgt_window *win, int width, int height) { - MoveWindow(win->handle, win->rect.x, win->rect.y, width, height, TRUE); + RECT rect; + win->rect.width = width; win->rect.height = height; + + rect.left = win->rect.x; + rect.top = win->rect.y; + rect.right = rect.left + width; + rect.bottom = rect.top + height; + if(AdjustWindowRect(&rect, WIN_STYLE, FALSE)) { + width = rect.right - rect.left; + height = rect.bottom - rect.top; + } + MoveWindow(win->handle, win->rect.x, win->rect.y, width, height, TRUE); } void wgt_quit_on_close(struct wgt_window *win, int quit)