![]() |
|
|
|
|
#1
|
|||
|
|||
|
Здравствуйте!
Есть форма, скажем описаная в Unit1.pas. Также есть написаный вручную клас, который лежит в Class.pas. Так вот, этот клас, который сидит в Class.pas должен работать с канвой формы из Unit1.pas, тоетсь рисовать на ней. Как это сделать? |
|
#2
|
||||
|
||||
|
Дабавьте в секцию Uses вашего модуля Class вызов Unit1
|
|
#3
|
||||
|
||||
|
http://data.cod.ru/76358
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Clas;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ACanvas:=Canvas;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
ClasFormPaint;
end;
end.Код:
unit Clas; interface uses Classes, Graphics; var ACanvas: TCanvas; procedure ClasFormPaint; implementation procedure ClasFormPaint; begin ACanvas.Brush.Color:=clYellow; ACanvas.FillRect(Rect(10, 10, 100, 100)); end; end. |