X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/962468d4b96c33869e9131eb42a0c784591f5884..33b1edda1f3fa65f5cad3b8a73cdc2fd61558ec9:/windows/winctrls.c diff --git a/windows/winctrls.c b/windows/winctrls.c index fa79e649..60e32f5e 100644 --- a/windows/winctrls.c +++ b/windows/winctrls.c @@ -2098,26 +2098,12 @@ void dlg_editbox_set(union control *ctrl, void *dlg, char const *text) SetDlgItemText(dp->hwnd, c->base_id+1, text); } -static char *getdlgitemtext_alloc(HWND hwnd, int id) -{ - char *ret = NULL; - int size = 0; - - do { - size = size * 4 / 3 + 512; - ret = sresize(ret, size, char); - GetDlgItemText(hwnd, id, ret, size); - } while (!memchr(ret, '\0', size-1)); - - return ret; -} - char *dlg_editbox_get(union control *ctrl, void *dlg) { struct dlgparam *dp = (struct dlgparam *)dlg; struct winctrl *c = dlg_findbyctrl(dp, ctrl); assert(c && c->ctrl->generic.type == CTRL_EDITBOX); - return getdlgitemtext_alloc(dp->hwnd, c->base_id+1); + return GetDlgItemText_alloc(dp->hwnd, c->base_id+1); } /* The `listbox' functions can also apply to combo boxes. */ @@ -2312,7 +2298,7 @@ Filename *dlg_filesel_get(union control *ctrl, void *dlg) char *tmp; Filename *ret; assert(c && c->ctrl->generic.type == CTRL_FILESELECT); - tmp = getdlgitemtext_alloc(dp->hwnd, c->base_id+1); + tmp = GetDlgItemText_alloc(dp->hwnd, c->base_id+1); ret = filename_from_str(tmp); sfree(tmp); return ret; @@ -2380,6 +2366,8 @@ void dlg_set_focus(union control *ctrl, void *dlg) struct winctrl *c = dlg_findbyctrl(dp, ctrl); int id; HWND ctl; + if (!c) + return; switch (ctrl->generic.type) { case CTRL_EDITBOX: id = c->base_id + 1; break; case CTRL_RADIO: