On Sun, 2 Dec 2012 16:27:13 -0800 (PST)
Alejandro Gonzalo <[email protected]> wrote:

> I am using Laz 1.04 for Win 7 64 bit.  I get error msg: Error: Incompatible 
> types: got "Pointer" expected "<procedure variable type of 
> procedure(TObject,var Char) of object;Register>"
> 
> 
> this is the procedure in a unit Implemetation section that I want to use for 
> OnKeyPress  (I also put the prototype in the Interface section):
> Procedure Rolodex(Sender: TObject; var Key: char);
>     var myTable : TAdsTable;   // I'm using Advantage Database Systems
>     begin
>     myTable:=TAdsTable(Form1.dbNavigator1.DataSource.Dataset);
>     if ((myTable.State = dsBrowse) AND
>         (Ord(Key) IN [32..126]) AND
>         (myTable.indexname<>'')) then
>       myTable.FindNearest([upcase(Key)]);
>     end;             
>  
> I loop through the form's components (Temp := myForm.Components[i];):
>     if ((Temp is TDBGrid) AND (TDBGrid(Temp).Parent = myPage)) then    
>       TDBGrid(Temp).OnKeyPress := @Rolodex;  //get error this line, also 
> without the @
>  
> This is in a separate unit not associated with a form but I assume that does 
> not matter (the unit is in the main form's Uses list in the Implementation 
> section).
> What did I leave out ?  Any help will be greatly appreciated!

OnKeyPress must be a method, i.e. a procedure of an object.
A normal procedure and a method are not compatible.

Mattias

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to