1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 09:27:59 +00:00

New Windows utility function: GetDlgItemTextW_alloc.

Just like the existing GetDlgItemText_alloc, but for wide strings.
This commit is contained in:
Simon Tatham 2023-05-29 13:31:14 +01:00
parent 392be3e494
commit 059f42aa56
2 changed files with 17 additions and 3 deletions

View File

@ -402,6 +402,7 @@ int message_box(HWND owner, LPCTSTR text, LPCTSTR caption, DWORD style,
bool utf8, DWORD helpctxid);
void MakeDlgItemBorderless(HWND parent, int id);
char *GetDlgItemText_alloc(HWND hwnd, int id);
wchar_t *GetDlgItemTextW_alloc(HWND hwnd, int id);
void split_into_argv(char *, bool includes_program_name,
int *, char ***, char ***);

View File

@ -1,7 +1,7 @@
/*
* Handy wrapper around GetDlgItemText which doesn't make you invent
* an arbitrary length limit on the output string. Returned string is
* dynamically allocated; caller must free.
* Handy wrappers around GetDlgItemText (A and W) which don't make you
* invent an arbitrary length limit on the output string. Returned
* string is dynamically allocated; caller must free.
*/
#include "putty.h"
@ -18,3 +18,16 @@ char *GetDlgItemText_alloc(HWND hwnd, int id)
return ret;
}
wchar_t *GetDlgItemTextW_alloc(HWND hwnd, int id)
{
wchar_t *ret = NULL;
size_t size = 0;
do {
sgrowarray_nm(ret, size, size);
GetDlgItemTextW(hwnd, id, ret, size);
} while (!memchr(ret, '\0', size-1));
return ret;
}