如何确定TJvDockServer表单是未固定还是固定? [英] How can you tell if a TJvDockServer Form is unpinned or pinned?

查看:94
本文介绍了如何确定TJvDockServer表单是未固定还是固定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道是否有人知道如何轻松地固定或取消固定TJvDockServer表单.我能够这样做的唯一方法是通过...检查父窗体是否为TJvDockVSPopupPanel.

I was just wondering if anybody knew how to determine if a TJvDockServer Form is pinned or unpinned easily. The only way I've been able to do so is by checking if a parent form is a TJvDockVSPopupPanel via...

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是...

and getAncestors is...

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,如下所示:

I would check DockState first, like this:

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;

Unpinned表示停靠样式支持双峰状态(单击时处于打开状态,单击时处于关闭状态),从固定状态(停靠时的默认状态)变为非固定(但仍停靠)状态,除了微小的名称外,该状态完全隐藏板标记.

Unpinned means that the dock style supports a bimodal (click it's on, click it's off) state change from pinned (the default state when you dock) to unpinned (but still docked) state which is entirely hidden except for a tiny name-plate marker.

我编写的上面的代码不会通过父代递归,因此无法处理您的代码试图处理的情况,这似乎是表单属于选项卡式笔记本的一部分,然后隐藏在JvDockVSPopupPanel内. (制作三页,然后通过取消固定将它们全部隐藏).在这种情况下,您将需要使用祖先"方法,但是我至少还是要添加检查到 TJvDockClient.DockState使用任何方法.

The above code I wrote does not recurse through parents, and so it does not handle the case that your code is trying to handle it seems, which is if the form is part of a tabbed notebook which is then hidden inside a JvDockVSPopupPanel. (Make three pages, then hide them all by unpinning). You would need to use the Ancestors approach in that case, but I would at least still add the check to TJvDockClient.DockState to whatever approach you use.

但是,您的方法似乎对3级递归进行了硬编码,因此可能仅适用于您的确切控件集,因此,我会考虑将其重写,例如:如果aForm在最近X代父辈中有一个父辈,那是一个TJvDockVSPopupPanel,然后返回true,否则返回false".

However, your approach which appears to hard code a 3 level recursion is probably only applicable to your exact set of controls, so I would consider rewriting it generally, by saying "If aForm has a parent within the last X generations of parents that is a TJvDockVSPopupPanel, then return true, otherwise return false".

这篇关于如何确定TJvDockServer表单是未固定还是固定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆