home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1999 March
/
Chip_1999-03_cd.bin
/
zkuste
/
delphi
/
INFO
/
DI9901RV.ZIP
/
PlgBltU.pas
Wrap
Pascal/Delphi Source File
|
1998-12-14
|
3KB
|
115 lines
unit PlgBltU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, Math;
type
TForm1 = class(TForm)
Img: TImage;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure FormMouseMove(Sender: TObject;
Shift: TShiftState; X,Y: Integer);
private
P : array[0..3] of TPoint;
OAng : array[0..3] of Double;
OverHandle : Integer;
BkBmp : TBitmap;
MidPt : TPoint;
Ang,R : Double;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var
Pt : Integer;
begin
BkBmp := TBitmap.Create;
BkBmp.Width := Width;
BkBmp.Height := Height;
P[0] := Img.BoundsRect.TopLeft;
P[3] := Img.BoundsRect.BottomRight;
P[1] := P[0]; Inc(P[1].X,Img.Width);
P[2] := P[3]; Dec(P[2].X,Img.Width);
with Img do
MidPt := Point(Left+Width div 2,Top + Height div 2);
with Img do
R := SqRt(Sqr(Width div 2) + Sqr(Height div 2));
for Pt := 0 to 3 do
with P[Pt] do
OAng[Pt]:= ArcTan2(Y-MidPt.Y,X-MidPt.X)+Pi;
OverHandle := -1;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
BkBmp.Free;
end;
procedure TForm1.FormPaint(Sender: TObject);
var
Pt : Integer;
begin
with BkBmp.Canvas do begin
Brush.Color := clBtnFace;
FillRect(ClipRect);
if PlgBlt(Handle,P,Img.Canvas.Handle,0,0,
Img.Width,Img.Height,0,0,0) then
begin
Brush.Color := clBlack;
for Pt := 0 to 3 do
with P[Pt] do
FillRect(Rect(X-3,Y-3,X+3,Y+3));
end
else
TextOut(0,0,'PlgBlt supported only on WinNT');
end;
Canvas.Draw(0,0,BkBmp);
end;
procedure TForm1.FormMouseMove(Sender: TObject;
Shift: TShiftState; X,Y: Integer);
var
Pt : Integer;
TmpRect : TRect;
begin
if ssLeft in Shift then
begin
if OverHandle = -1 then
Exit;
Ang := ArcTan2(Y-MidPt.Y,X-MidPt.X) -
OAng[OverHandle]+Pi;
for Pt := 0 to 3 do
P[Pt] := Point(MidPt.X-Round(R*Cos(Ang+OAng[Pt])),
MidPt.Y-Round(R*Sin(Ang+OAng[Pt])));
Paint;
end
else
begin
OverHandle := -1;
for Pt := 0 to 3 do begin
with P[Pt] do
TmpRect := Rect(X-3,Y-3,X+3,Y+3);
if PtInRect(TmpRect,Point(X,Y)) then
begin
Cursor := crHandPoint;
OverHandle := Pt;
end;
end;
if OverHandle = -1 then
Cursor := crDefault;
end;
end;
end.