对于Form来说:
var
I: Integer;
F: TCustomForm;
begin
F := nil;
for I := 0 to Screen.FormCount-1 do
begin
if Screen.Forms.Canvas = lCanvas then
begin
//Screen.Forms就是lCanvas的拥有者
F := Screen.Forms;
Break;
end;
end;
if Assigned(F) then ...
end;
//这是我的想法,不知有没有更好的方法
procedure TForm1.Button1Click(Sender: TObject);
var
tr:TRect;
begin
tr:=form1.Canvas.ClipRect;
showmessage(inttostr(tr.Right-tr.Left));
showmessage(inttostr(tr.bottom-tr.top));