如何判断TJvDockServer表单是取消固定还是固定



我只是想知道是否有人知道如何轻松确定TJvDockServer表单是固定还是取消固定。我能做到这一点的唯一方法是通过…检查父窗体是否是TJvDockVSPopupPanel。。。

ancestor := GetAncestors(Self, 3);
if (ancestor is TJvDockTabHostForm) then
    if ancestor.Parent <> nil then
    begin
        if ancestor.Parent is TJvDockVSPopupPanel then
        begin
            // Code here
        end;  
    end;

getAncestors是…

function GetAncestors(Control : TControl; AncestorLevel : integer) : TWinControl;
begin
    if (Control = nil) or (AncestorLevel = 0) then
        if Control is TWinControl then
            result := (Control as TWinControl)
        else
            result := nil // Must be a TWinControl to be a valid parent.
    else
        result := GetAncestors(Control.Parent, AncestorLevel - 1);
end; 

我会先检查DockState,如下所示:

function IsUnpinned(aForm:TMyFormClassName):Boolean;
begin
  result := false;
 if Assigned(aForm) then
    if aForm.Client.DockState = JvDockState_Docking then
    begin
      // it's docked, so now try to determine if it's pinned (default state,
      // returns false) or unpinned (collapsed/hidden) and if unpinned, return true.
      if aForm.Client.DockStyle is TJvDockVSNetStyle then
      begin
        if Assigned(aForm.Parent) and (aForm.Parent is TJvDockVSPopupPanel) then
        begin
          result := true;
        end;
      end;  
    end;
end;

未固定意味着固定样式支持从固定(固定时的默认状态(到未固定(但仍然固定(状态的双峰(单击它打开,单击它关闭(状态更改,除了一个小的铭牌标记外,该状态完全隐藏。

我写的上面的代码不会通过父级递归,因此它不会处理您的代码试图处理的情况,也就是说,如果表单是选项卡式笔记本的一部分,然后隐藏在JvDockVSPopupPanel中。(制作三页,然后通过取消固定将其全部隐藏(。在这种情况下,您需要使用Ancestors方法,但我至少仍然会将检查添加到TJvDockClient.DockState适用于您使用的任何方法。

然而,你的方法似乎是硬编码的3级递归,可能只适用于你的确切控件集,所以我会考虑一般重写它,说"如果aForm在最后X代父级中有一个父级是TJvDockVSPopupPanel,那么返回true,否则返回false"。

最新更新