Hi!
Instead of pass 'TheCanvas' pass your own class as user parameter.
An example with a form.
Simply change the TForm1 for your class type
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure MyProc(X,Y: Integer; TheForm: TForm1); stdcall;
begin
TheForm.Memo1.Lines.Add( Format('Point: %d,%d',[x,y]) );
//Here you can get your canvas or anything of your class...
//TheForm.Canvas....
end;
procedure TForm1.Button1Click(Sender
begin
LineDDA(10,10,20,20,@MyPro
end;
end.
Main Topics
Browse All Topics





by: BlackTigerXPosted on 2005-09-15 at 08:11:26ID: 14889974
in MyProc you can use any values of MyVcl, by referencing it's instance, weird that you didn't use the "T" naming convention, but usually it would be something like:
c,LongInt( Canvas));
procedure MyProc(X,Y: Integer; TheCanvas: TCanvas); stdcall;
begin
whatever:=MyVcl.Color; //MyVCL would be the instance, and you have access to it here
end;
procedure TMyVcl.DoSomething; //this is a method implementation on the TMyVCL class
begin
....
LineDDA(X1,Y1,X2,Y1,@MyPro
....
end;