We use DELPHI7 development application system process often need to use child windows in the main window docking function, if this part is not skilled, usually to csdn and other sites to find a variety of related controls, or refer to the Delphi with the routine docking, Let me introduce a simple method that can be used together.
1, in the main window to add four panel and four splitter, set alignment up and down four sides.
2, set the properties of the four panel Docksite property is true.
3, left and right panel to add Ondockdrop, Ondockover, Onundock events are as follows:
procedure TfrmMain.pnlLeftUnDock(Sender: TObject; Client: TControl;
NewTarget: TWinControl; var Allow: Boolean);
begin
if (Sender as TPanel).VisibleDockClientCount = 1 then
begin
(Sender as TPanel).Width := 1;
end;
end;
procedure TfrmMain.pnlLeftDockDrop(Sender: TObject;
Source: TDragDockObject; X, Y: Integer);
begin
(Sender as TPanel).Width := max(source.Control.UndockWidth,(Sender as TPanel).Width);
end;
procedure TfrmMain.pnlLeftDockOver(Sender: TObject;
Source: TDragDockObject; X, Y: Integer; State: TDragState;
var Accept: Boolean);
begin
if State = dsDragEnter then
begin
(Sender as TPanel).Width := max(Source.Control.UndockWidth, (Sender as TPanel).Width);
end
else
begin
if State = dsDragLeave then
begin
(Sender as TPanel).Width := 1;
end;
end;
end;
The left and right panel response event code is the same.