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
精彩评论