Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compute LPWSTR size when using GetDlgItemText() function

Tags:

c++

winapi

My request is small I am using GetDlgItem() to get text from a text field , but I have a problem in the fourth parameter (i.e. size of buffer) .

LPWSTR txtbuff;
GetDlgItemText(hwnd, IDC_EDIT1, txtbuff, 50); // the fourth parameter (50)
MessageBox(NULL,txtbuff,L"Error message",MB_OK)

How can I compute size of txtbuff

like image 801
Lion King Avatar asked Feb 18 '12 12:02

Lion King


1 Answers

You can use GetDlgItem to get the control's HWND and GetWindowTextLength to determine how many characters are held by your control.

like image 169
Ferruccio Avatar answered Oct 03 '22 20:10

Ferruccio