procedure TfrmMain.DoShowHint(var HintStr: String; var CanShow: Boolean; var HintInfo: THintInfo); begin if HintInfo.HintControl is TPageControl then // TPageControl类型使用 //if HintInfo.HintControl = Button2 then // 单个按钮使用 HintInfo.HintWindowClass := THkHintWindow else HintInfo.HintWindowClass := THintWindow; // 其它类型使用原有Hint end;
type TPageControl = class(Vcl.ComCtrls.TPageControl) private FTabRect: array of TRect; // Tab Rect procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW; end;
procedure TPageControl.CMHintShow(var Message: TCMHintShow); var Id: integer;
function MouseAt(X, Y: integer): integer; begin for Result := 0 to Length(FTabRect) - 1 do begin if PtInRect(FTabRect[Result], Point(X, Y)) then Exit; end;
Result := -1; end;
begin with Message.HintInfo^ do begin Id := MouseAt(CursorPos.X, CursorPos.Y); if Id <> -1 then begin HintStr := Self.Pages[Id].Hint; CursorRect := FTabRect[Id]; HintData := TCustomData(Ord(alTop)); // Hint箭头方向 end else HintStr := ''; end; end;