Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- TCircleImage = class(TCustomControl)
- protected
- procedure Paint; override;
- public
- constructor Create(AOwner: TComponent); override;
- end;
- type
- TForm1 = class(TForm)
- Image1: TImage;
- procedure CircleImageMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- CircleImage: TCircleImage;
- implementation
- {$R *.DFM}
- constructor TCircleImage.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- Width:= 100;
- Height:= 100;
- end;
- procedure TCircleImage.Paint;
- var aRect: TRect;
- begin
- aRect:= Rect(0, 0, 100, 100);
- Canvas.CopyRect(aRect, Form1.Image1.Canvas, aRect);
- end;
- procedure TForm1.CircleImageMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- var aHandle: THandle;
- begin
- aHandle:= (Sender as TCircleImage).Handle;
- BringWindowToTop(aHandle);
- ReleaseCapture;
- SendMessage(aHandle, WM_NCLBUTTONDOWN, 2, 0); // 2 = HTCAPTION
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- CircleImage:= TCircleImage.Create(Self);
- CircleImage.Parent:= Self;
- SetWindowRgn(CircleImage.Handle, CreateEllipticRgn(0, 0, 100, 100), true);
- CircleImage.OnMouseDown:= CircleImageMouseDown;
- CircleImage.Left:= 10;
- CircleImage.Top:= 10;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement