I have a dialog box with two buttons: Cancel and Ok,
which use IDs IDCANCEL and IDOK, respectively. I want to
disable the Cancel button under some circumstances, so I
tried the following code:

SendDlgItemMessage(hDlg, IDCANCEL, WM_ENABLE, (WPARAM)
FALSE, (LPARAM)0);

It doesn't appear to do anything. The Cancel button is
still available. I can, however, hide it with the
following code:

ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_HIDE);

Any ideas why I can't disable it?

Thanks,
Don

Re: Can't disable button in dialog by Doug

Doug
Wed Aug 20 17:49:10 CDT 2003

Hi Don,

Use EnableWindow.

Cheers

Doug Forster

"Don Woods" <drwoods@attglobal.net> wrote in message
news:02b901c3674f$35ed7e60$a401280a@phx.gbl...
> I have a dialog box with two buttons: Cancel and Ok,
> which use IDs IDCANCEL and IDOK, respectively. I want to
> disable the Cancel button under some circumstances, so I
> tried the following code:
>
> SendDlgItemMessage(hDlg, IDCANCEL, WM_ENABLE, (WPARAM)
> FALSE, (LPARAM)0);
>
> It doesn't appear to do anything. The Cancel button is
> still available. I can, however, hide it with the
> following code:
>
> ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_HIDE);
>
> Any ideas why I can't disable it?
>
> Thanks,
> Don



Re: Can't disable button in dialog by Don

Don
Wed Aug 20 19:23:33 CDT 2003

Thanks, Doug

That worked liked a charm.

Don
>-----Original Message-----
>Hi Don,
>
>Use EnableWindow.
>
>Cheers
>
>Doug Forster
>
>"Don Woods" <drwoods@attglobal.net> wrote in message
>news:02b901c3674f$35ed7e60$a401280a@phx.gbl...
>> I have a dialog box with two buttons: Cancel and Ok,
>> which use IDs IDCANCEL and IDOK, respectively. I want
to
>> disable the Cancel button under some circumstances, so
I
>> tried the following code:
>>
>> SendDlgItemMessage(hDlg, IDCANCEL, WM_ENABLE, (WPARAM)
>> FALSE, (LPARAM)0);
>>
>> It doesn't appear to do anything. The Cancel button is
>> still available. I can, however, hide it with the
>> following code:
>>
>> ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_HIDE);
>>
>> Any ideas why I can't disable it?
>>
>> Thanks,
>> Don
>
>
>.
>

Re: Can't disable button in dialog by Doug

Doug
Thu Aug 21 23:39:12 CDT 2003

Hi Sergei,

WM_ENABLE message is sent by Windows to a window simply to tell the window
concerned that its state has changed, not to initiate the state change.

Cheers

Doug Forster

"Sergei V." <sv@i_a_e.nsk.su> wrote in message
news:OyR26BFaDHA.2580@TK2MSFTNGP12.phx.gbl...
>
> > Thanks, Doug
> > That worked liked a charm.
> > Don
>
> That's fine.
> Could anybody explain why the first (SendDlgItemMessage(...) ) won't work?
> s.v.
>
> > >-----Original Message-----
> > >Hi Don,
> > >
> > >Use EnableWindow.
> > >
> > >Cheers
> > >
> > >Doug Forster
> > >
> > >"Don Woods" <drwoods@attglobal.net> wrote in message
> > >news:02b901c3674f$35ed7e60$a401280a@phx.gbl...
> > >> I have a dialog box with two buttons: Cancel and Ok,
> > >> which use IDs IDCANCEL and IDOK, respectively. I want
> > to
> > >> disable the Cancel button under some circumstances, so
> > I
> > >> tried the following code:
> > >>
> > >> SendDlgItemMessage(hDlg, IDCANCEL, WM_ENABLE, (WPARAM)
> > >> FALSE, (LPARAM)0);
> > >>
> > >> It doesn't appear to do anything. The Cancel button is
> > >> still available. I can, however, hide it with the
> > >> following code:
> > >>
> > >> ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_HIDE);
> > >>
> > >> Any ideas why I can't disable it?
> > >>
> > >> Thanks,
> > >> Don
> > >
> > >
> > >.
> > >
>
>