终于解决了,试验了好久:
------------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus, ExtCtrls;
type TMyControl = Class(TControl);
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
private
procedure MyMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.MyMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
(Sender as TControl).Perform(WM_SYSCOMMAND,$F012,0);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
I:Integer;
begin
for I:=0 to Form1.ComponentCount-1 do
begin
if (Form1.Components is TControl) then
begin
TMyControl(Form1.Components).OnMouseDown:=MyMouseDown;
end;
end;
end;
end.