如何判断TJvDockServer表单是否已取消固定或固定?

时间:2013-01-07 10:23:58

标签: delphi delphi-2010 jvcl

我只是想知道是否有人知道如何确定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; 

1 个答案:

答案 0 :(得分:2)

我会首先检查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“。

相关问题