Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set button to disable 1

Status
Not open for further replies.

HyperEngineer

Programmer
May 8, 2002
190
0
0
US

How do you set a button control to disable. I can see in this property at design time, but can't seem to find how to access it at run time. When the button is clicked, I would like to disable it so that the user can't click it again. Is this possible? Or do I have to do it with flags?


HyperEngineer
If it ain't broke, it probably needs improvement.
 
Code:
  // MFC
  button.EnableWindow (FALSE);
 
  // SDK
  EnableWindow (hwndButton, FALSE);
 

xwb,

Thanks for the reply.

My program is an MFC Dialog based program. I have a button with nID IDC_GET_DATA. I can use GetDlgItem to get a handle to the control, but I'm not sure how to use this to get a name to use in the dot notation.

I tried to use the SDK solution, but it would only let me have on argument. When I do that, the whole dialog box is disabled not just that one button.

I would like to use the MFC solution if I can figure out how to get "button". Could you steer me in the right direction for this?

thanks,

HyperEngineer
If it ain't broke, it probably needs improvement.
 
Try
Code:
GetDlgItem (IDC_GET_DATA).EnableWindow(FALSE);
 

xwb

Works like a champ here at home. I will try it at work, but I know it's going to work there as well.

Thanks,

HyperEngineer
If it ain't broke, it probably needs improvement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top