反复实验,终于成功了,给你看看。
procedure TForm1.PageControl1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var I:Integer;
begin
if Button =mbleft then
begin
i:=PageControl1.IndexOfTabAt(x,y);
if (i>-1) and (i<PageControl1.PageCount) then
begin
PageControl1.BeginDrag(False);
end;
end;
end;
procedure TForm1.PageControl1DragOver(Sender, Source: TObject; X,
Y: Integer; State: TDragState; var Accept: Boolean);
var i:Integer;
begin
if Source is TPageControl then
begin
i:=PageControl1.IndexOfTabAt(x,y);
Accept := (i > -1) and (i <> PageControl1.ActivePageIndex) and (i < PageControl1.PageCount);
end;
end;
procedure TForm1.PageControl1DragDrop(Sender, Source: TObject; X,
Y: Integer);
var i,j:Integer;
begin
if source is TPageControl then
begin
i:=PageControl1.ActivePageIndex;
j:=PageControl1.IndexOfTabAt(x,y);
if (j>-1) and (j<>i) then
begin
PageControl1.ActivePage.PageIndex:=j;
end;
end;
end;
end.