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, 16);
delete [] myVar;
我只需要掌握控件的HWND ,将其发送给WM_GETTEXTLENGTH并将答案与零进行比较即可。
您可能必须使用IPM_ISBLANK
消息(我不是winapi的专家,所以我可能会误会)。
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
参见此处: GetWindowText函数
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.