wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.lpszClassName = win->cname;
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.lpszClassName = win->cname;
+void wgt_enable_widget(struct wgt_widget *w)
+{
+ w->disabled = 0;
+ EnableWindow(w->handle, 1);
+}
+
+void wgt_disable_widget(struct wgt_widget *w)
+{
+ w->disabled = 1;
+ EnableWindow(w->handle, 0);
+}
+
+int wgt_widget_enabled(struct wgt_widget *w)
+{
+ return !w->disabled;
+}
+
if(!(w = calloc(1, sizeof *w))) {
fprintf(stderr, "wgt_checkbox: failed to allocate widget structure\n");
if(!(w = calloc(1, sizeof *w))) {
fprintf(stderr, "wgt_checkbox: failed to allocate widget structure\n");
if(width < 0 || height < 0) {
wgt_string_size(win, text, &textsz);
if(width < 0 || height < 0) {
wgt_string_size(win, text, &textsz);
- max_width = max_height = sum_height = 0;
+ wgt_string_size(win, "00", &textsz);
+ max_width = width < 0 && width != WGT_AUTO ? -width : textsz.width;
+ max_height = height < 0 && height != WGT_AUTO ? -height : textsz.height;
+ sum_height = num_items ? 0 : max_height;
for(i=0; i<num_items; i++) {
wgt_string_size(win, items[i], &textsz);
for(i=0; i<num_items; i++) {
wgt_string_size(win, items[i], &textsz);
WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS,
x, y, width, height, win->handle, 0, GetModuleHandle(0), 0))) {
fprintf(stderr, "wgt_combo: failed to create window\n");
WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS,
x, y, width, height, win->handle, 0, GetModuleHandle(0), 0))) {
fprintf(stderr, "wgt_combo: failed to create window\n");
- SendMessage(w->handle, CB_SETCURSEL, sel, 0);
+ if(sel >= 0) {
+ SendMessage(w->handle, CB_SETCURSEL, sel, 0);
+ }
default:
return DefWindowProc(wnd, msg, wparam, lparam);
}
default:
return DefWindowProc(wnd, msg, wparam, lparam);
}