Ok, here is a test program where I'm just trying to access the Tedit field on the form from the keydown event.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ComCtrls, StdCtrls,Functions;
type
{ TForm1 }
TForm1 = class(TForm)
Edit1: TEdit;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
);
begin
Form1.Edit1.Caption := 'HI';
MyKeyPress(Sender,Key,Shift);
end;
initialization
{$I unit1.lrs}
end.
------------------------------------------------------------------------------------------
unit Functions;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,Dialogs,Forms;
Function MyKeyPress(Sender: TObject; var Key: Word; Shift: TShiftState):Boolean;
implementation
Function MyKeyPress(Sender: TObject; var Key: Word; Shift: TShiftState):Boolean;
begin
if Sender is TForm then
begin
tform(Sender).Edit1.Caption := 'BYE';
end;
end;
end.
-----------------------------------------------------------------------------------------------
This doesn't work because I get the error:
functions.pas(16,18) Error: identifier idents no member "Edit1"
So how do I correctly access the field in this instance??