Board index » delphi » Can I assign message handlers at runtime?

Can I assign message handlers at runtime?

Hi there.  Is it possible to assign window message traps at runtime?
I'd like to do the following: trap WM_MOVING when OS is Win95 but trap
WM_WINDOWPOSChanging when OS is WinNT.

Thanks,
Steve

 

Re:Can I assign message handlers at runtime?


This is a multi-part message in MIME format.
--------------62F0BF3573B990915057D1C3
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Yes you can. You have to overwrite the WndProc method of the control and
check there is the message you want to catch was sent.

Quote
Stephen Smith wrote:

> Hi there.  Is it possible to assign window message traps at runtime?
> I'd like to do the following: trap WM_MOVING when OS is Win95 but trap
> WM_WINDOWPOSChanging when OS is WinNT.

> Thanks,
> Steve

--
Jose Sebastian Battig

---------------------------------------------------

Important:

Please, when replying to me delete the "STOPSPAM-"
part of the "reply to" e-mail address.

Por favor cuando me contestes usando "reply" borra
la parte de la direccion que dice "STOPSPAM-".
--------------62F0BF3573B990915057D1C3
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Jose Sebastian Battig
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Jose Sebastian Battig
n:              Battig;Jose Sebastian
org:            Softech
adr:            ;;;San Miguel de Tucumn;Tucumn;4000;Argentina
email;internet: STOPSPAM-k...@iname.com
note:           It's important to make you note that you should delete the "STOPSPAM-" part of my E-Mail address to send me a message. I really hate Spamers!!
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard

--------------62F0BF3573B990915057D1C3--

Re:Can I assign message handlers at runtime?


Hi,

Quote
>Hi there.  Is it possible to assign window message traps at runtime?
>I'd like to do the following: trap WM_MOVING when OS is Win95 but trap
>WM_WINDOWPOSChanging when OS is WinNT.

You can either overload WndProc, and catch' the one you need right
there.

Or you can write handlers for both and ignore the one you don't need.
Like (don't know the names of the message-record-types, check in
messages.pas):

In the form's declaration:

Quote
> procedure WMMoving(var Msg:TWMMoving); message WM_Moving;
> procedure WMWindowPosChanging(var Msg:TWMWindowPosChanging); message WM_WindowPosChanging;

In the implementation:

Quote
> procedure TForm1.Moving;
>   begin {So something special} end;

> procedure TForm1.WMMoving(var Msg:TWMMoving);
>   begin if Win95 then Moving; inherited end;

> procedure TForm1.WMWindowPosChanging(var Msg:TWMWindowPosChanging); message WM_WindowPosChanging;
>   begin if WinNT then Moving; inherited end;

Ciao, MM
--
Fon: +49 228 624013 Fax: +49 228 624031
"Was schiefgehen kann, geht auch schief."

Other Threads