我是想实现PageCtrol管理功能
1、左边是一个菜单树
2、右边是一个PageCtrol, 每一页是一个窗体 (返回dll的Form对象, 一个dll可能有多个Form)
3、单击一个菜单就PageCtrol就动态加载一页(dll中的窗体)
3、双击页标签就关掉一个功能(窗体)  LibModule := LoadLibrary(Project.dll');
  if LibModule = 0 then
    MessageBox(NULL, 'Error', 'wang', MB_OK or MB_ICONERROR)
  else
  begin
    Entry := GetProcAddress(LibModule, 'Entry');
    if Entry = nil then
      begin
        MessageBox(NULL, 'Error2', 'wang2', MB_OK or MB_ICONERROR);
        FreeLibrary(LibModule);
        LibModule := 0;
      end
    else
      Form := TEntry(Entry);//获得一个窗体对象
  end;
  ///PageCtrol加载一个窗体
  //动态创建tabsheet和panel
   TheTabSheet := TTabSheet.Create(Self);
   TheTabSheet.PageControl := PageControl1;
   ThePanel:=Tpanel.Create(self);
   ThePanel.Parent:= TheTabSheet;
   ThePanel.Align:=alClient;
   //ThePanel.DockSite:=true;  // 将ThePanel.DockSite:=true则出现关闭条
   //载入一个窗体到TAbsheet
   //application.CreateForm(TForm2,Form2);
   SetRect(Rect, 0, 0, 500, 500);
   Form.Dock(ThePanel,Rect);
   Form.show;
   TheTabSheet.Caption:=Form.Caption;
   TheTabSheet.Show;
  //////////////////////   双击关闭页
  procedure TForm1.PageControl1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  Index: Integer;
begin
  if (Button = mbLeft) and (ssDouble in Shift) then
  begin
    Index := PageControl1.IndexOfTabAt(X, Y);    //if  LibModule <> 0 then
   // FreeLibrary(LibModule);
    if Index >= 0 then
      PageControl1.Pages[Index].Free;
  end;
end;
我想问一下在我双击关闭PageContorl页是, 需要先去释放dll, 才能正常关闭某页, 但有可能其它PageCtorl页也调用用了dll的的窗体, 因为dll有多个窗体,实现了多个功能,不知道如何正常关闭某页.  直接这样关闭是会有错了if Index >= 0 then
      PageControl1.Pages[Index].Free;