Board index » delphi » RegisterWindowMessage & Delphi 3 message handling

RegisterWindowMessage & Delphi 3 message handling

I want to set up a unique inter-process message using
RegisterWindowMessage. Easy enough to do in C. But in Delphi, I want to
write a message handler based on that message. Problem is, what do I
declare for the 'message' parameter in the function definition? Variables
haven't been defined yet, so I'd have to use a const, which of course
can't be assigned the return value of RegisterWindowMessage. Is there
some alternate way for declaring message handlers in Delphi?

Thanks for your help,
Jason

 

Re:RegisterWindowMessage & Delphi 3 message handling


In article <MPG.1033dbd683a5b996989...@news.concentric.net>, Jason Taylor
(ja...@nethorse.com) says...

Quote

<snip>
> Is there
> some alternate way for declaring message handlers in Delphi?

For messages registered with RegisterWindowMessage, you have to override
WinProc and do it the old-fashioned way. Well, almost, WinProc is a
method on a WinControl, so you don't have to worry about what object
you're working on. Self is correct.

M.

--
Ettertraktet kaffe, er det ekstra god kaffe?
mailto:martin.lars...@delfidata.no.NOSPAM
http://www.delfidata.no/users/~martin

Re:RegisterWindowMessage & Delphi 3 message handling


Jason,

Quote
> write a message handler based on that message. Problem is, what do I
> declare for the 'message' parameter in the function definition?

You don't. You have to use a replacement WndProc for the form, and
use an if statement to test for the message value:

implementation

var
   MyMessage: Integer;

procedure TForm1.FormCreate(Sender: TObject);
begin
   MyMessage := RegisterWindowMessage('Your Message');
end;

procedure TForm1.FormWndProc(var Msg: TMessage);
begin
   if Msg.Message = MyMessage then
      // Do whatever.
   inherited;
end;

Ken
--
Ken White
kwh...@westelcom.com

Clipper Functions for Delphi
http://members.aol.com/clipfunc/

Quote
Jason Taylor wrote:

> I want to set up a unique inter-process message using
> RegisterWindowMessage. Easy enough to do in C. But in Delphi, I want to
> write a message handler based on that message. Problem is, what do I
> declare for the 'message' parameter in the function definition? Variables
> haven't been defined yet, so I'd have to use a const, which of course
> can't be assigned the return value of RegisterWindowMessage. Is there
> some alternate way for declaring message handlers in Delphi?

> Thanks for your help,
> Jason

Other Threads