#include <commctrl.h>
#include "widgets.h"
+#define WIN_STYLE WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME
+
struct wgt_window {
HWND handle;
struct wgt_rect rect;
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;
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)