我的一个界面在动态库中,如果想把动态库的界面显示的主界面的一个Tpanel上(也就是把动态库中界面的父窗口设为主界面的Tpanel上),如何实现,请高手指教

解决方案 »

  1.   

    用:
    Windows.SetParent
    就可!
      

  2.   

    ihOld := Windows.GetParent(ih);
        SetProp(ih, 'OldParent', GetParent(ih));
        Windows.SetParent(ih, TabSheet2.Handle);    Style := GetWindowLong(ih, GWL_STYLE);
        StyleEx := GetWindowLong(ih, GWL_EXSTYLE);
        SetProp(ih, 'OldStyle', Style);
        SetProp(ih, 'OldStyleEx', StyleEx);    SetWindowLong(ih, GWL_STYLE, ((Style or WS_CHILD) and not (WS_POPUP or WS_BORDER)));
        SetWindowLong(ih, GWL_EXSTYLE, ((Style or WS_EX_CONTROLPARENT)));
        SetWindowPos(ih, HWND_TOP, 2, 2, 0, 0, SWP_SHOWWINDOW or SWP_NOSIZE);    ShowWindow(ih, SW_SHOWMAXIMIZED);得到你的Panel.handle 和窗體的Handle 就可!
    我的例子是設置到 TabSheet2 上的
      

  3.   

    以下的内容对不对,显示的时候有些内空显示不出来
      frmCInfoQuery.BorderStyle := bsNone;
      frmCInfoQuery.Align := alClient;
      Windows.SetParent(frmCInfoQuery.Handle, parent);
      frmCInfoQuery.Show;
      

  4.   

    var
      f: TfrmUserPower;
      I: Integer;
    begin
        for i := 0 to Panel.ControlCount - 1 do
        begin
          if Panel9.Controls[i].InheritsFrom (TfrmUserPower) then
          begin
            f := TfrmUserPower(Panel.Controls[i]);
            Panel.RemoveControl(f);
            freeAndNil(f);
          end;
        end;
        F := TfrmUserPower.Create(Panel);
        Panel.DockSite := True;
        with F do
        begin
          DockSite := True;
          DragKind := DkDock;
          Align := alClient;
          HostDockSite := Panel;
          Show;
        end;
      end;