Board index » delphi » Non-Visual component events

Non-Visual component events

Hi,

I've been struggling with something for quite a while but can't find a
solution. The problem is that I want to create a console application and I
want to use a TClienSocket with it. This implies that I won't be able to
visually access the properties  of the component and need to access them
manually. I'm stuck at this part because I can't figure out how to make the
component respond to events such as OnConnect, OnDisconnect, etc. Anyone can
help me? Thanks

--

Arvind

 

Re:Non-Visual component events


Quote
Arvind Doobary wrote in message ...
>Hi,

>I've been struggling with something for quite a while but can't find a
>solution. The problem is that I want to create a console application and I
>want to use a TClienSocket with it. This implies that I won't be able to
>visually access the properties  of the component and need to access them
>manually. I'm stuck at this part because I can't figure out how to make
the
>component respond to events such as OnConnect, OnDisconnect, etc. Anyone
can
>help me? Thanks

ASocket.OnConnect:=AnObject.AHandler;

That a property is published doesn't mean it's _only_ accessible
through the object inspector. It's still public in all other
respects.

There is one other catch, which is in the difference between
procedures and methods. A method is always in the context of a
known object, which must be given as a qualifier to unambiguously
specify the method.

The easiest way out is to use a data module, but many people don't
want to do this because they switched to a console application to
keep executable size down (which is a mistake, but that's another
story). But classes can be declared and instantiated without the
usual visual baggage. Just add a unit, write the class with the
event handlers in it (derive from TClientSocket perhaps, and set
event handlers already in the constructor?), and start instantiating
objects and setting properties.

Groetjes,
Maarten Wiltink

Re:Non-Visual component events


Thanks a lot for your help!!!! I'll try out the new ideas asap :))

Best regards,
Arvind

Quote
"Maarten Wiltink" <maar...@kittensandcats.net> wrote in message

news:a317g0$q0b$1@news1.xs4all.nl...
Quote
> Arvind Doobary wrote in message ...
> >Hi,

> >I've been struggling with something for quite a while but can't find a
> >solution. The problem is that I want to create a console application and
I
> >want to use a TClienSocket with it. This implies that I won't be able to
> >visually access the properties  of the component and need to access them
> >manually. I'm stuck at this part because I can't figure out how to make
> the
> >component respond to events such as OnConnect, OnDisconnect, etc. Anyone
> can
> >help me? Thanks

> ASocket.OnConnect:=AnObject.AHandler;

> That a property is published doesn't mean it's _only_ accessible
> through the object inspector. It's still public in all other
> respects.

> There is one other catch, which is in the difference between
> procedures and methods. A method is always in the context of a
> known object, which must be given as a qualifier to unambiguously
> specify the method.

> The easiest way out is to use a data module, but many people don't
> want to do this because they switched to a console application to
> keep executable size down (which is a mistake, but that's another
> story). But classes can be declared and instantiated without the
> usual visual baggage. Just add a unit, write the class with the
> event handlers in it (derive from TClientSocket perhaps, and set
> event handlers already in the constructor?), and start instantiating
> objects and setting properties.

> Groetjes,
> Maarten Wiltink

Other Threads