+struct wgt_widget *wgt_progbar(struct wgt_window *win, int x, int y, int width, int height, int p)
+{
+ struct wgt_widget *w;
+ INITCOMMONCONTROLSEX commctrl;
+
+ commctrl.dwSize = sizeof commctrl;
+ commctrl.dwICC = ICC_PROGRESS_CLASS;
+ InitCommonControlsEx(&commctrl);
+
+ if(!(w = calloc(1, sizeof *w))) {
+ fprintf(stderr, "wgt_progbar: failed to allocate widget structure\n");
+ return 0;
+ }
+ w->win = win;
+
+ if(height < 0) {
+ height = GetSystemMetrics(SM_CYVSCROLL);
+ }
+
+ if(!(w->handle = CreateWindow(PROGRESS_CLASS, 0, WS_CHILD | WS_VISIBLE, x, y,
+ width, height, win->handle, 0, GetModuleHandle(0), 0))) {
+ fprintf(stderr, "wgt_progbar: failed to create window\n");
+ free(w);
+ return 0;
+ }
+
+ /*
+ SendMessage(w->handle, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
+ SendMessage(w->handle, PBM_SETSTEP, 1, 0);
+ */
+ SendMessage(w->handle, PBM_SETPOS, p, 0);
+
+ w->rect.x = x;
+ w->rect.y = y;
+ w->rect.width = width;
+ w->rect.height = height;
+
+ w->next = win->wlist;
+ win->wlist = w;
+ return w;
+}
+
+void wgt_set_text(struct wgt_widget *w, const char *text)
+{
+ SendMessage(w->handle, WM_SETTEXT, 0, (long)text);
+
+ w->rect.width = wgt_string_size(w->win, text, 0);
+ MoveWindow(w->handle, w->rect.x, w->rect.y, w->rect.width, w->rect.height, TRUE);
+}
+