I have a number of forms tabdocked in a JvDocking Page Control, but the tabs are too small to display the entire form caption.
Is there anyway to display a hint containing the tab text when the tab is hovered over?
The closest I've gotten is a hint on each form:
TJvDockVIDTabPageControl(Form).Pages[i].Hint := 'hint';
and one hint on the entire panel of tabs:
TJvDockVIDTabPageControl(Form).Panel.Hint := 'hint';
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;