Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 Mar : TComponent and TMessage

www.cryer.info
Managed Newsgroup Archive

TComponent and TMessage

Subject:TComponent and TMessage
Posted by:"Tobias" (tobias_..@hotmail.com)
Date:Wed, 28 Mar 2007 16:39:32

Hello,
I have a componente that creates a TThread class i now want to send a
message form the TThread decendent.
I tryed to override the components WndProc and have the tthread send a
message to to the component,
but the sendmessage wants a window handle so only the window is receiving
the messages how can i receive messages in the component?

const  CM_ON_MY_MSG = WM_USER + 1;


TThreadDecendent = class(TThread)
  .
  .
  .
  procedure Execute; override;
end;

TMyComp = class(TImage)
  .
  .
  .
  FThread : TThreadDescendent;
  procedure WndProc(var Message : TMessage) ; override;
end;

procedure TMyComp.WndProc(...);
begin
   if Message.msg = CM_ON_MY_MSG then begin
      //do some handling
     exit;
   end;
   inherited WndProc(Message);
end;

procedure TThreadDecendent .Execute;
begin
  try
     StrToInt('s');
  excpet
     SendMessage(Need to send this message to the component (handle),
CM_ON_MY_MSG , 0, 0 );
  end;
end;

Replies:

www.cryer.info
Managed Newsgroup Archive