Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to write a component which can auto enable and disable

0 views
Skip to first unread message

lzh

unread,
Jun 7, 2002, 4:21:56 AM6/7/02
to
I want to write a component which can auto enable or disable when active
control is or is not TCustomEdit.

I know if I inherite from TCustomAction to write a TMyAction, I can override
TCustomAction.HandlesTarget/UpdateTarget method to get this ability. But the
component I want to write is TCustomComboBox, I do not know how to do.

I have read the code about TBasicAction, TContainedAction, TCustomAction,
but I am so foolish and do not know why TAction have this ability.

Could you help me? Thank you very much!

Lasse Vågsæther Karlsen

unread,
Jun 7, 2002, 7:29:49 AM6/7/02
to
"lzh" <l...@43210.com> wrote in news:3d006e92$1_2@dnews:

If I understand you correctly, you want to create a new component, that
changes its Enabled property depending on if the active control of the form
is a TCustomEdit or not, sort of run code like this:

Self.Enabled := (Parent as TForm).ActiveControl is TCustomEdit;

and the problem is (probably) that you don't know how to get this code to
run at the correct places.

One solution I've used is to use an TApplicationEvents component
internally, and use the OnIdle event handler of that component to be
notified when the program is entering idle state.

--
Lasse Vågsæther Karlsen
PGP KeyID: 0x0270466B

940801

unread,
Jun 7, 2002, 3:55:44 PM6/7/02
to
Yes, you understand me. Thank you very much.
You are right, TApplicationEvents.OnIdle can do.

I find another way to do this. As you know, TControl have a property --
Action. I use this Action to solve my question.


Lasse Vågsæther Karlsen

unread,
Jun 8, 2002, 4:52:15 AM6/8/02
to
"940801" <l94...@yahoo.com> wrote in news:3d010f57_2@dnews:

> I find another way to do this. As you know, TControl have a property --
> Action. I use this Action to solve my question.

If you create an action object internally, and use its OnUpdate event
handler you are in fact using the same system :)

0 new messages