Board index » cppbuilder » Dynamic control event firing in thread object

Dynamic control event firing in thread object

I'm writing a simple server-type program in which I need to process
request messages I receive. I intend to handle each request separately
in a
thread by itself. I've created a TSession class which I derive from
TThread.
As part of the TSession class I include a third-party HTTP
component/control
(which is normally visually manipulated via the IDE -- I'm trying to
avoid
this). When I create the thread object, as part of normal construction I
instantiate the control too. The problem I'm having is that I can't get
the
third-party's control to fire its events (such as OnConnected(),
OnTransferBegin(), OnTransferEnd(), etc.).
The questions I have are:
1) What do I need to do to get the component's events to fire correctly?
2) The component's constructor needs a TComponent* Owner value, and
right now I'm passing a pointer to the main form. Is this ok?

Here's a rough outline of the class declaration:

class TSessionThread : public TThread
{
private:    // Private declarations
   char     *p_chRequestPkt;
   char     *p_chResponsePkt;
   THTTP    *p_HTTP;             // HTTP component for this thread
object
   // .
   // . other stuff
   // .

Quote
};

Any help will be much appreciated.

Thanks!

Dom.

 

Re:Dynamic control event firing in thread object


After constructing p_HTTP, p_HTTP -> Parent = your main form. Now you can
write event handlers for THTTP in your main form.
Quote
"Bede J. Dominick" wrote:
> I'm writing a simple server-type program in which I need to process
> request messages I receive. I intend to handle each request separately
> in a
> thread by itself. I've created a TSession class which I derive from
> TThread.
> As part of the TSession class I include a third-party HTTP
> component/control
> (which is normally visually manipulated via the IDE -- I'm trying to
> avoid
> this). When I create the thread object, as part of normal construction I
> instantiate the control too. The problem I'm having is that I can't get
> the
> third-party's control to fire its events (such as OnConnected(),
> OnTransferBegin(), OnTransferEnd(), etc.).
> The questions I have are:
> 1) What do I need to do to get the component's events to fire correctly?
> 2) The component's constructor needs a TComponent* Owner value, and
> right now I'm passing a pointer to the main form. Is this ok?

> Here's a rough outline of the class declaration:

> class TSessionThread : public TThread
> {
> private:    // Private declarations
>    char     *p_chRequestPkt;
>    char     *p_chResponsePkt;
>    THTTP    *p_HTTP;             // HTTP component for this thread
> object
>    // .
>    // . other stuff
>    // .
> };

> Any help will be much appreciated.

> Thanks!

> Dom.

Other Threads