Using the example provided here How to implement a close button for a TTabsheet of a TPageControl combined with setting a forms parent to a tab sheet with matching caption I was able to take my pagecontrol with forms attached as TTabSheet and add a close button and image from an image list much like you see on today's web browsers.
When I change
procedure TMainfrm.SOTest(Sender: TObject);
var
ATab: TTabSheet;
AForm: TMyForm;
begin
{ Tabbed }
ATab:= TTabSheet.Create(MainPageControl);
ATab.PageControl := MainPageControl;
MainPageControl.ActivePage := ATab;
AForm:= TMyForm.Create(ATab);
AForm.Show;
ATab.Caption := AForm.Caption;
end;
to
procedure TMainfrm.SOTest(Sender: TObject);
var
AForm: TMyForm;
begin
AForm:= TMyForm.Create(Application);
AForm.Show;
AForm.DragKind := dkDock;
AForm.DragMode := dmAutomatic;
AForm.ManualDock(MainPageControl,MainPageControl,alClient);
AForm.Caption := 'StackOverFlow';
end;
The OnMouse events do not pick up on any docked forms thus causing the close button to stop working.