4

我在 JvDocking 页面控件中有许多表单选项卡,但选项卡太小而无法显示整个表单标题。

无论如何,当标签徘徊在盘旋上时,是否有显示包含标签文本的提示?

我得到的最接近的是每种形式的提示:

TJvDockVIDTabPageControl(Form).Pages[i].Hint := 'hint';

以及整个选项卡面板上的一个提示:

TJvDockVIDTabPageControl(Form).Panel.Hint := 'hint';
4

1 回答 1

3

You can't use Hint, as it doesn't appear to refresh the hint as you navigate over the tabs. Therefore you need to override TJvDockTabPanel.MouseMove() and do something like this:

inherited MouseMove(Shift, X, Y)
Index := GetPageIndexFromMousePost(X, Y)
// Your code here
if (Index > -1) then
begin
    // Strip hotkey '&' out.
    Hint := StringReplace(Page.Pages[Index].Caption, '&', '', [rfReplaceAll]);
    Application.ActivateHint(ClientToScreen(Point(X, Y)));
end;

You can either fork JvDockVIDStyle.pas and make changes, or subclass it to provide your own functionality, then inject that class into your dockstyle. Here's a rough example of how:

unit JvDockExtVIDStyle;

interface

uses JvDockVIDStyle, Classes;

type
    TJvDockExtTabPanel = class(TJvDockTabPanel)
    protected
        procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
    end;

    TJvDockExtVIDTabPageControl = class(TJvDockVIDTabPageControl)
    public
        constructor Create(AOwner: TComponent); override;
    end;

implementation

uses Forms, SysUtils;

{ TJvDockExtVIDTabPageControl }

constructor TJvDockExtVIDTabPageControl.Create(AOwner: TComponent);
begin
    inherited Create(AOwner);
    //Override TabPanel with our subclassed version
    TabPanelClass := TJvDockExtTabPanel;
end;

{ TJvDockExtTabPanel}

procedure TJvDockExtTabPanel.MouseMove(Shift: TShiftState; X, Y: Integer);
var
    Index : Integer;
begin
    inherited MouseMove(Shift, X, Y);

    Index := GetPageIndexFromMousePos(X, Y);
    if (Index > -1) then
    begin
        Hint := StringReplace(Page.Pages[Index].Caption, '&', '', [rfReplaceAll]);
        Application.ActivateHint(ClientToScreen(Point(X, Y)));
    end;
end;

Then you can implement it in your main form create by overriding the TabDockClass on your dock style to use our subclassed one. Like so:

DockStyle.TabDockClass := TJvDockExtVIDTabPageControl;
DockServer.DockStyle := DockStyle;

This works for VSNET style as well. Just replace VID with VSNet wherever it appears and inherit from TJvDockVSNetTabPanel instead of TJvDockTabPanel

Update

There is now an update in the JVCL trunk which will do this. Update your components and set the ShowTabHints property on your dock style to true. Or do it in code.

MyDockStyle.ShowTabHints := True;
于 2013-11-28T16:41:02.870 回答