Board index » delphi » Disabling controls in a TDialog?

Disabling controls in a TDialog?

Hi everyone.

How do I disable (gray out)/reenable controls like TEdit's in a TDialog (in
response to a checkbox in the dialog being unchecked/checked, respectively).

Thanks,
Will Bryant
brya...@winston.riccarton.school.nz

 

Re:Disabling controls in a TDialog?


In article <b007.68.0009A...@winston.riccarton.school.nz>, b...@winston.riccarton.school.nz (Will Bryant) says:

Quote

>Hi everyone.

>How do I disable (gray out)/reenable controls like TEdit's in a TDialog (in
>response to a checkbox in the dialog being unchecked/checked, respectively).

>Thanks,
>Will Bryant
>brya...@winston.riccarton.school.nz

You need to send a message to the control(s) that you want to disable:

SendDlgItemMessage(Hwindow,ID,EM_SetReadOnly,Word(true),0);

where HWindow is the window handle of the dialog and ID is the id
number of the control.

Hope this helps,
Jochen

________________________________________________________________________
joch...@berlin.snafu.de                        74754.2...@compuserve.com
I post, therefore I am.

Re:Disabling controls in a TDialog?


To disable/enable TDialog elements ...

        EnableWindow(GetDlgItem(HWindow, id_Take), True);

HWindow is the HWnd of the dialog box, id_Take is the ID of the element, True enables the element.
 False would disable the element.  I have found that making the element disabled by default
helps.

Re:Disabling controls in a TDialog?


Quote
mjon...@ent.agt.ab.ca wrote:
>To disable/enable TDialog elements ...

>        EnableWindow(GetDlgItem(HWindow, id_Take), True);

>HWindow is the HWnd of the dialog box, id_Take is the ID of the element, True enables the element.
> False would disable the element.  I have found that making the element disabled by default
>helps.

I seem to recall that when you disable an edit control, the text contained
within it disappears, as opposed to greying out.  That may be a problem
depending on the reason for disabling the control.
--

             - Dan Solomon,  dsolo...@pyrotechnics.com
                           http://www.pyrotechnics.com/~dsolomon//------------------------------...
|           "No amount of planning will ever replace dumb luck"            |
\--------------------------------------------------------------------------/
"At that moment, an event--or is 'event' the word for it?--takes place which
 cannot be described, and hence no attempt will be made to describe it."

Other Threads