Subj : Re: Trying to set up a Response table for a dervied thread class but not working... To : borland.public.cpp.borlandcpp From : Antsy Date : Sun Jun 06 2004 06:18 am Hi again. I have done what you said and have had some success. I've dervied the class from both TWindow and Thread, and in turn the class is now picking up the events and processing the ones it needs to process...but there is one final hurdle (due to the fact that I am not too sure how to set up a message loop in the run method with out messing with the messaging processing of the entire application.) So what I did is below. I just have the run funtion looping indefinitely...whats not there is a mechnisi m that i can call to exit the loop in the Run() method. Its there just not in the listing below. Now the problem is that when the Main application windows does a lenthy process, this thread below seems to stop processing messages until the lengthy process is completed in the Main application. But since this is a thread...I thought it would continue to do what it does while other things are happening. Maybe i should have a message loop in the Run() like you said. If so can you point me towards somewhere that does this in the context of threads. My thing is I can't visulize how it would be done, without someway affecting the message processing of the main window. ******NOTE i have removed the details to shorten the listing *** #if !defined(foo_h) // Sentry, use file only if it's not already included. #define foo_h #include class TFoo : public TWindow, public TThread { public: TFoo(TWindow* parent); ~TFoo(); TWindow* par; private: int Run(); LRESULT foohandler(WPARAM wParam, LPARAM lParam); HWND EventHandlerObject; protected: virtual void SetupWindow(); DECLARE_RESPONSE_TABLE(TFoo); }; #endif #include #include "foo.h" DEFINE_RESPONSE_TABLE1(TFoo, TWindow) //{{TFoo_TBL_BEGIN}} EV_REGISTERED("USMSG_FOO_EVENT", foohandler), //{{TFoo_TBL_END}} END_RESPONSE_TABLE; TFoo::TFoo(TWindow *parent) : TWindow(parent), TThread() { } void TFoo::SetupWindow() { TWindow::SetupWindow(); EventHandlerObject = this->GetHandle(); } TFoo::~TFoo() { Destroy(); } TFoo::Run() { for (;;) { Sleep(100); } return 0L; } LRESULT TFoo::foohandler(WPARAM wParam, LPARAM lParam) { return 0L; } "Bruce Salzman" wrote: >> On reading it appears that I can have any class and set it up like this >> and from my understanding it should be able to have events. > >While true that you can derive directly from TEventHandler, OWL's message >processing mechanism uses the parent/child window relationship to handle the >(convoluted) routing of messages. Also, message queues need a window handle >for Windows to send messages to. If you want your thread to process messages >like your main window, create an invisible window in your thread. Then you >can set up a message processing loop in its Run() method. > >Bruce > > >--- >Outgoing mail is certified Virus Free. >Checked by AVG anti-virus system (http://www.grisoft.com). >Version: 6.0.699 / Virus Database: 456 - Release Date: 6/4/04 > > .