How do I disable an EDITTEXT?
Scenario:
I have an EDITTEXT control and a PUSHBUTTON control.
I want to click the push button, and it will then set the EDITTEXT style to WS_DISABLED.
Is there a simple function I have overlooked, or what?
Printable View
How do I disable an EDITTEXT?
Scenario:
I have an EDITTEXT control and a PUSHBUTTON control.
I want to click the push button, and it will then set the EDITTEXT style to WS_DISABLED.
Is there a simple function I have overlooked, or what?
Look up EnableWindow() and GetDlgItem() in your Windows documentation.
I am not so sure you understand what I want.
Here is the example source...
resource.rc
main.cppCode:#include "resource.h"
DLG_MAIN DIALOGEX 6, 5, 194, 106
STYLE 0x10CE0804
BEGIN
CONTROL "&Disable", IDC_BTN_DISABLE, "Button", 0x10010000, 138, 5, 46, 15
CONTROL "&Quit", IDC_BTN_QUIT, "Button", 0x10010000, 138, 29, 46, 15
EDITTEXT 3, 10, 10, 100, 10
END
Or am I misunderstanding you?Code:...
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_BTN_QUIT:
EndDialog(hwndDlg, 0);
return TRUE;
case IDC_BTN_DISABLE:
//Disable the EDITTEXT control: what should be here?
return TRUE;
}
...
You want to selectively enable and disable windows controls...
Part of your problem may be that your EDITTEST in your resources is poorly formed as it does not return an identifier.
Code:...
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_BTN_QUIT:
EndDialog(hwndDlg, 0);
return TRUE;
case IDC_BTN_DISABLE:
EnableWindow(GetDlgItem(hDialog,IDC_EDIT),0);
return TRUE;
}
...
EnableWindow needs the window handle of the control (which is wehre GetDlgItem() is used) and either a 1 to enable the window or a 0 to disable it. For a button, it's greyed and you can't click it. For an edit box, it's greyed and you can't type into it (but it still shows content). etc.Quote:
Or am I misunderstanding you?
EnableWindow Function (Windows)