开发者

Check if a textbox control is empty C++ Win32

开发者 https://www.devze.com 2023-02-05 15:28 出处:网络
i have this code that put the value of a textbox field in the variable. The textbox is a Ip Address Control. How can i check if when the user press the OK button the field is empty or not? Thank you

i have this code that put the value of a textbox field in the variable. The textbox is a Ip Address Control. How can i check if when the user press the OK button the field is empty or not? Thank you

char *myVar = new char[16];
*myVar = NULL;

GetDlgItemTextA(hDlg, IDC_MYVAR, myVar开发者_如何学Python, 16);

delete [] myVar;


You probably have to use the IPM_ISBLANK message (i am not an expert on winapi, so i may be mistaken).


I'd just get hold of the HWND for the control, send it a WM_GETTEXTLENGTH and compare the answer with zero.


Just check whether myVar[0] is zero after calling GetDlgItemTextA.

char myVar[16];
GetDlgItemTextA(hDlg, IDC_MYVAR, myVar, 16);
if (myVar[0] == 0) // then field is empty


See here: GetWindowText Function

0

精彩评论

暂无评论...
验证码 换一张
取 消