[Lazarus] assigning OnKeyPress at runtime
Alejandro Gonzalo
parkingspace26 at yahoo.com
Mon Dec 3 01:27:13 CET 2012
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!
A. G.
More information about the Lazarus
mailing list