Enable a control/window in an MFC dialog, Resolved
-
Windows XP, Visual Studio 2008, MFC, Dialog, c++ A button in the main MFC dialog opens a second dialog with options to control the main app. In there is a button that starts disable and after a method is run, is to be enabled. The event handler that initiates that task and enables the button looks like this, so far:
void C_Prog_Control::OnBnClickBtnGetCurrentStates()
{
HWND *button_handle = NULL;
BOOL status = FALSE;
Get_Current_States();
GetDlgItem( IDC_DO_THIS, &button_handle )
status = EnableWindow( button_handle, TRUE ); // error
}Please forgive, but not ignore, any obvious typos as my work computer is in another room and cannot be connected to the internet. I cannot cut and paste. And now that's worse. I cannot post a message from work and must send the text home and post from there. I have looked up the GetDlgItem() here: (When I paste in the Microsoft URL it will not display.) And the EnableWindow function here: (Same for this link). So the first looks like this on the MS web site:
HWND WINAPI GetDlgItem(
_In_opt_ HWND hDlg,
_In_ int nIDDlgItem
);and the second looks like this:
BOOL WINAPI EnableWindow(
_In_ HWND hWnd,
_In_ BOOL bEnable
);The EnableWindow code will not compile. The error is: … error C2660: ‘CWnd::EnableWindow’ : function does not take 2 arguments. The compiler does not see, or does not like that I want HWND::EnableWindow rather than CWnd. When I try to use CWnd there are other problems. Intellisense shows the following signature: BOOL EnableWindow( BOOL bEnable = 1 ) This differs from the MS page and there is only one signature. So, given a button with the ID of: IDC_DO_THIS, how can I enable it? EDIT RESOLVED While at work, I stopped what I was doing several times and searched for the answer to this several times at work, through the Air Force Firewalls. After giving up there and posting this question from home, I finally found the good idea of searching from home. There in one of the first few pages was a good answer. Tried it, it worked. Just for the record:
void Cvs_2008_get_port_numberDlg::OnBnClickedButton3()
{
CWnd *pfield = GetDlgItem( IDC_BUTTON2 );
pfield->EnableWindow( FALSE );
}My lesson, try a search at work, but if it does not turn up the answer, search again from home. I presume the Air Force, and all military sites, are attacked so often that they have little choice but to set up things the way they are.
Th
-
Windows XP, Visual Studio 2008, MFC, Dialog, c++ A button in the main MFC dialog opens a second dialog with options to control the main app. In there is a button that starts disable and after a method is run, is to be enabled. The event handler that initiates that task and enables the button looks like this, so far:
void C_Prog_Control::OnBnClickBtnGetCurrentStates()
{
HWND *button_handle = NULL;
BOOL status = FALSE;
Get_Current_States();
GetDlgItem( IDC_DO_THIS, &button_handle )
status = EnableWindow( button_handle, TRUE ); // error
}Please forgive, but not ignore, any obvious typos as my work computer is in another room and cannot be connected to the internet. I cannot cut and paste. And now that's worse. I cannot post a message from work and must send the text home and post from there. I have looked up the GetDlgItem() here: (When I paste in the Microsoft URL it will not display.) And the EnableWindow function here: (Same for this link). So the first looks like this on the MS web site:
HWND WINAPI GetDlgItem(
_In_opt_ HWND hDlg,
_In_ int nIDDlgItem
);and the second looks like this:
BOOL WINAPI EnableWindow(
_In_ HWND hWnd,
_In_ BOOL bEnable
);The EnableWindow code will not compile. The error is: … error C2660: ‘CWnd::EnableWindow’ : function does not take 2 arguments. The compiler does not see, or does not like that I want HWND::EnableWindow rather than CWnd. When I try to use CWnd there are other problems. Intellisense shows the following signature: BOOL EnableWindow( BOOL bEnable = 1 ) This differs from the MS page and there is only one signature. So, given a button with the ID of: IDC_DO_THIS, how can I enable it? EDIT RESOLVED While at work, I stopped what I was doing several times and searched for the answer to this several times at work, through the Air Force Firewalls. After giving up there and posting this question from home, I finally found the good idea of searching from home. There in one of the first few pages was a good answer. Tried it, it worked. Just for the record:
void Cvs_2008_get_port_numberDlg::OnBnClickedButton3()
{
CWnd *pfield = GetDlgItem( IDC_BUTTON2 );
pfield->EnableWindow( FALSE );
}My lesson, try a search at work, but if it does not turn up the answer, search again from home. I presume the Air Force, and all military sites, are attacked so often that they have little choice but to set up things the way they are.
Th
When searching MSDN for a particular Windows function you will generally find two links. One of them wil be in the form
FunctionName(parameters)
, and the otherClassname::FunctionName(parameters)
. If you are coding pure Win32 then you take the first form, and if you are using MFC you take the second. There are certain functions that do not have MFC equivalents, but that is generally clear from the context. -
When searching MSDN for a particular Windows function you will generally find two links. One of them wil be in the form
FunctionName(parameters)
, and the otherClassname::FunctionName(parameters)
. If you are coding pure Win32 then you take the first form, and if you are using MFC you take the second. There are certain functions that do not have MFC equivalents, but that is generally clear from the context.I had not noticed that, but will take the time to look for it now. It will probably help to incorporate those into my searches. Thank you for taking the time to post that.
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com