ATL / WTL / STL
|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:
HWND *button_handle = NULL;
BOOL status = FALSE;
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?
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:
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.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 8-Oct-14 22:20pm.
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.