unit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
Panel1: TPanel;
ListBox1: TListBox;
Label1: TLabel;
Edit1: TEdit;
procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormPaint(Sender: TObject);
procedure Edit1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
const sc_dragmove = $f012;
begin
ReleaseCapture;
TWinControl(Sender).perform(wm_syscommand,sc_dragmove, 0);
//Statt Sender kann im Konkreten Fall auch Panel1 stehen
//Der OriginalQuelltext verschiebt so ein TEdit
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
if Sender
is TPanel
then begin
Label1.Left := TWinControl(Sender).Left;
Label1.Top := TWinControl(Sender).Top - Label1.Height;
end;
end;
procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Panel1MouseDown(Sender,Button,Shift,X,Y);
end;
end.