--- a/ui/win32/window.c Wed Oct 08 10:41:35 2025 +0200 +++ b/ui/win32/window.c Wed Oct 08 12:36:16 2025 +0200 @@ -41,6 +41,7 @@ #include "win32.h" static W32WidgetClass w32_toplevel_widget_class = { + .eventproc = ui_window_widget_event, .show = ui_window_widget_show, .enable = NULL, .get_preferred_size = NULL, @@ -52,6 +53,10 @@ static const char *mainWindowClass = "UiMainWindow"; LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + W32Widget *widget = (W32Widget*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + if (widget && widget->wclass->eventproc) { + widget->wclass->eventproc(widget, hwnd, uMsg, wParam, lParam); + } switch(uMsg) { case WM_DESTROY: PostQuitMessage(0); @@ -98,13 +103,15 @@ UpdateWindow(hwnd); - W32Widget *widget = w32_widget_new(&w32_toplevel_widget_class, hwnd); - obj->widget = widget; - obj->ref = 1; + // TODO: switch to box container + UiContainerX *container = ui_grid_container_create(obj, hwnd, 0, 0, INSETS_ZERO); + uic_object_push_container(obj, container); - // TODO: switch to box container - UiContainerX *container = ui_grid_container_create(obj, hwnd, 0, 0, 0, 0); - uic_object_push_container(obj, container); + UiWindow *widget = w32_widget_create(&w32_toplevel_widget_class, hwnd, sizeof(UiWindow)); + widget->obj = obj; + widget->container = (UiGridLayoutContainer *)container; + obj->widget = (W32Widget*)widget; + obj->ref = 1; return obj; } @@ -113,6 +120,19 @@ return create_window(title, window_data, FALSE); } + +void ui_window_widget_event(W32Widget *widget, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + UiWindow *window = (UiWindow*)widget; + switch (uMsg) { + case WM_SIZE: { + int width = LOWORD(lParam); + int height = HIWORD(lParam); + ui_grid_layout(window->container->layout, width, height); + break; + } + } +} + void ui_window_widget_show(W32Widget *w, BOOLEAN show) { ShowWindow(w->hwnd, show ? SW_SHOWNORMAL : SW_HIDE); }