Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-10

Method in WndClassEX

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luis Del Aguila

Puedo colocar un método en el campo lpfnWndProc del registro WndClassEX Es decir algo parecido a esto :

VAR
  ClaseVentana : WndClassEX;
   ...
   ClaseVentana.lpfnWndProc := WndProc(Método);

***************************** TRANSALATE *******************************

may I allocate a metthod in the field lpfnWndProc of the WndClassEX Registers?
Like this :

VAR
  ClaseVentana : WndClassEX;
   ...
   ClaseVentana.lpfnWndProc := WndProc(Método);

Reply by email

Jonas Maebe
to Luis Del Aguila
Luis Del Aguila wrote 9 lines
may I allocate a metthod in the field lpfnWndProc of the WndClassEX Registers? Like this : VAR ClaseVentana : WndClassEX; ... ClaseVentana.lpfnWndProc := WndProc(Método);

No, you cannot assign methods to normal procedure variables, only normal procedures. The reason is that methods always expect an extra parameter containing the self pointer of the object/class instance they are working on. If you do the above, then when windows calls you "wndproc" (which isn't really a wndproc, since you have to add an explicit type cast for the compiler to accept the statement), it won't pass any self pointer and as such the method will not work correctly.

Jonas

Reply by email

Luis Del Aguila

Message: 4
Date: Fri, 12 Oct 2001 15:53:25 +0200
Subject: Re: [fpc-pascal]Method in WndClassEX
From: Jonas Maebe
To:
Reply-To:

Luis Del Aguila wrote 9 lines
may I allocate a metthod in the field lpfnWndProc of the WndClassEX Registers? Like this : VAR ClaseVentana : WndClassEX; ... ClaseVentana.lpfnWndProc := WndProc(Método);

No, you cannot assign methods to normal procedure variables, only normal procedures. The reason is that methods always expect an extra parameter containing the self pointer of the object/class instance they are working on. If you do the above, then when windows calls you "wndproc" (which isn't really a wndproc, since you have to add an explicit type cast for the compiler to accept the statement), it won't pass any self pointer and as such the method will not work correctly.

Jonas

Existe alguna manera de pasar un metodo al registro lpfnWndProc usando ensamblador o algo mejor?

Do you know when allocate a metthod in the field lpfnWndProc of the WndClassEX using Assembler or something best?

Reply by email

Jonas Maebe
to Luis Del Aguila
Luis Del Aguila wrote 13 lines
> No, you cannot assign methods to normal procedure variables, only normal > procedures. The reason is that methods always expect an extra parameter > containing the self pointer of the object/class instance they are > working on. If you do the above, then when windows calls you "wndproc" > (which isn't really a wndproc, since you have to add an explicit type > cast for the compiler to accept the statement), it won't pass any self > pointer and as such the method will not work correctly. Existe alguna manera de pasar un metodo al registro lpfnWndProc usando ensamblador o algo mejor? Do you know when allocate a metthod in the field lpfnWndProc of the WndClassEX using Assembler or something best?

As I said: no, there is no way to use a method instead of a normal procedure as a call-back if the call-back is supposed to be a normal procedure. No matter how much assembler you use, Windows will never pass a self pointer to your method.

Jonas

Reply by email

Carlo Kok
to Jonas Maebe

----- Original Message -----

Earlier message 41 lines
From: "Jonas Maebe" To: Sent: Saturday, October 13, 2001 11:14 PM Subject: Re: [fpc-pascal]Re: Method in WndClassEX > > > On Sat, 13 Oct 2001, Luis Del Aguila wrote: > > >> No, you cannot assign methods to normal procedure variables, only normal > >> procedures. The reason is that methods always expect an extra parameter > >> containing the self pointer of the object/class instance they are > >> working on. If you do the above, then when windows calls you "wndproc" > >> (which isn't really a wndproc, since you have to add an explicit type > >> cast for the compiler to accept the statement), it won't pass any self > >> pointer and as such the method will not work correctly. > > > > Existe alguna manera de pasar un metodo al registro lpfnWndProc usando > > ensamblador o algo mejor? > > > > Do you know when allocate a metthod in the field lpfnWndProc of the > > WndClassEX using Assembler or something best? > > As I said: no, there is no way to use a method instead of a normal > procedure as a call-back if the call-back is supposed to be a normal > procedure. No matter how much assembler you use, Windows will never pass a > self pointer to your method. You could call SetWindowLong and set the pointer there and read it later. > > > Jonas > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >

Reply by email