您可以重新激活您覆盖的提示MouseMove
,例如:
type
TDBGrid = class(DBGrids.TDBGrid)
private
FLastHintColumn: Integer;
protected
procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
function GetColumnTitleHint(Col: Integer): string;
procedure MouseMove(Shift: TShiftState; X: Integer; Y: Integer); override;
public
constructor Create(AOwner: TComponent); override;
end;
procedure TDBGrid.CMHintShow(var Message: TCMHintShow);
var
Cell: TGridCoord;
begin
if not Assigned(Message.HintInfo) or not (dgTitles in Options) then
inherited
else
begin
Cell := MouseCoord(Message.HintInfo^.CursorPos.X, Message.HintInfo^.CursorPos.Y);
if Cell.Y = 0 then
begin
FLastHintColumn := Cell.X - 1;
Message.HintInfo^.HintStr := GetColumnTitleHint(FLastHintColumn);
end
else
FLastHintColumn := -1;
end;
end;
function TDBGrid.GetColumnTitleHint(Col: Integer): string;
begin
Result := Columns[Col].Title.Caption + ' hint';
end;
procedure TDBGrid.MouseMove(Shift: TShiftState; X, Y: Integer);
var
Cell: TGridCoord;
begin
inherited MouseMove(Shift, X, Y);
if dgTitles in Options then
begin
Cell := MouseCoord(X, Y);
if Cell.Y = 0 then
begin
if Cell.X - 1 <> FLastHintColumn then
Application.ActivateHint(Mouse.CursorPos);
end
else
Application.CancelHint;
end;
end;
constructor TDBGrid.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FLastHintColumn := -1;
end;
GetColumnTitleHint
只是一个示例,您应该实现它以从您的TitleHints
属性中返回正确的值。
希望这可以帮助。