Advertisement
TLama

Untitled

Jun 22nd, 2015
474
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.67 KB | None | 0 0
  1. type
  2.   // this is the structure that will be passed between your control and its hint window
  3.   TMyHintData = record
  4.     FontSize: Integer;
  5.     // and whatever else; you can pass even the reference to your control if it helps you
  6.   end;
  7.  
  8.   TMyHintWindow = class(THintWindow)
  9.   private
  10.     FMyHintData: TMyHintData;
  11.   public
  12.     procedure ActivateHintData(ARect: TRect; const AHint: string; AData: TCustomData); override;
  13.   end;
  14.  
  15.   TMyButton = class(TButton)
  16.   private
  17.     FMyHintData: TMyHintData;
  18.     procedure CMHintShow(var AMessage: TCMHintShow); message CM_HINTSHOW;
  19.   public
  20.     constructor Create(AOwner: TComponent); override;
  21.   end;
  22.  
  23. implementation
  24.  
  25. { TMyHintWindow }
  26.  
  27. procedure TMyHintWindow.ActivateHintData(ARect: TRect; const AHint: string; AData: TCustomData);
  28. begin
  29.   inherited;
  30.   // you can copy the passed record so you can access it later when you'll be painting
  31.   FMyHintData := TMyHintData(AData^);
  32. end;
  33.  
  34. { TButton }
  35.  
  36. constructor TMyButton.Create(AOwner: TComponent);
  37. begin
  38.   inherited;
  39.   // initialize you own hint window data structure; you can modify it at any time, it is passed
  40.   // to the hint window instance before it's displayed, through the CM_HINTSHOW handler; on the
  41.   // hint window class side will be received through the ActivateHintData method
  42.   FMyHintData.FontSize := 123;
  43. end;
  44.  
  45. procedure TMyButton.CMHintShow(var AMessage: TCMHintShow);
  46. begin
  47.   inherited;
  48.   // assign the custom data to the field; this will be passed through the ActivateHintData method
  49.   // of your hint window class
  50.   AMessage.HintInfo.HintData := @FMyHintData;
  51.   // set the hint window class
  52.   AMessage.HintInfo.HintWindowClass := TMyHintWindow;
  53. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement