Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- // this is the structure that will be passed between your control and its hint window
- TMyHintData = record
- FontSize: Integer;
- // and whatever else; you can pass even the reference to your control if it helps you
- end;
- TMyHintWindow = class(THintWindow)
- private
- FMyHintData: TMyHintData;
- public
- procedure ActivateHintData(ARect: TRect; const AHint: string; AData: TCustomData); override;
- end;
- TMyButton = class(TButton)
- private
- FMyHintData: TMyHintData;
- procedure CMHintShow(var AMessage: TCMHintShow); message CM_HINTSHOW;
- public
- constructor Create(AOwner: TComponent); override;
- end;
- implementation
- { TMyHintWindow }
- procedure TMyHintWindow.ActivateHintData(ARect: TRect; const AHint: string; AData: TCustomData);
- begin
- inherited;
- // you can copy the passed record so you can access it later when you'll be painting
- FMyHintData := TMyHintData(AData^);
- end;
- { TButton }
- constructor TMyButton.Create(AOwner: TComponent);
- begin
- inherited;
- // initialize you own hint window data structure; you can modify it at any time, it is passed
- // to the hint window instance before it's displayed, through the CM_HINTSHOW handler; on the
- // hint window class side will be received through the ActivateHintData method
- FMyHintData.FontSize := 123;
- end;
- procedure TMyButton.CMHintShow(var AMessage: TCMHintShow);
- begin
- inherited;
- // assign the custom data to the field; this will be passed through the ActivateHintData method
- // of your hint window class
- AMessage.HintInfo.HintData := @FMyHintData;
- // set the hint window class
- AMessage.HintInfo.HintWindowClass := TMyHintWindow;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement