10

I creating a program, i need : after click Button A, do something, and disable button A (mean that button is selected, not to be continue clicked !)

I see MSDN this page: http://msdn.microsoft.com/en-us/library/windows/desktop/bb849162%28v=vs.85%29.aspx

but I don't known using this (I also use it as function but : error: Button_Enable not identified)

VanPers
  • 339
  • 3
  • 6
  • 12

3 Answers3

11

Or you can use code like this ::EnableWindow(hBtn,false)

wshcdr
  • 935
  • 2
  • 12
  • 27
8

To use Button_Enable macro, You need to insert

#include <windowsx.h>

in your header file.

Or, you can use EnableWindow() function:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646291%28v=vs.85%29.aspx

machine_1
  • 4,266
  • 2
  • 21
  • 42
cristiano
  • 339
  • 1
  • 3
  • 13
4

Or you can use EnableWindow with getting window handle if your dialog box that contains the control which need to disable:

EnableWindow(GetDlgItem(hwndDlg,BTN_TRIM),false); // to disable button or other control
EnableWindow(GetDlgItem(hwndDlg,BTN_TRIM),true);  // to enable button or other control

hwndDlg - A handle to the dialog box that contains the control
BTN_TRIM - The identifier of the control to be retrieved

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Vladimir
  • 109
  • 1
  • 2