Hi,
I'm developing a GUI in C++ using dev-c++.
I have an edit control like this:
hctrl = CreateWindowEx(
0,
"EDIT", /* Nombre de la clase */
"", /* Texto del título, no tiene */
ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP |
ES_NUMBER , /* Estilo */
85, 43, /* Posición */
90, 25, /* Tamaño */
hwnd, /* Ventana padre */
(HMENU)ID_TEXTO2, /* Identificador del control */
hInstance, /* Instancia */
NULL); /* Sin datos de creación de ventana */
SendMessage(hctrl, WM_SETFONT, (WPARAM)hfont,
MAKELPARAM(TRUE, 0));
I want users to introduce a phone number in this field. It's a compulsory field.
I need that the OK button of this GUI is disabled until the field is correctly fill. It could be possible also that you could push the button but a message was shown saying you have to fill the empty field.
I tried this:
switch (HIWORD(wParam)) {
case BN_CLICKED:
switch (LOWORD(wParam)) {
...
...
case ID_BOTON9:
hctrl = GetDlgItem(hwnd,ID_TEXTO2);
len = GetWindowTextLength(GetDlgItem(hwnd,ID_TEXTO2));
if (len == 0)
MessageBox(hctrl, "Número no válido","Error", MB_ICONEXCLAMATION | MB_OK);
break;
...
}
break;
}
But this doesn't work.
Can anybody shed any light on it?
Thanks in advance.