| | |
TStringGrid per-cell tooltips?
Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2008
Posts: 9
Reputation:
Solved Threads: 0
Hi All,
I'm using a TStringGrid (has to be Delphi 7, and no 3rd party components) I've customised it to allow per-cell colouring/fonts/borders/validation etc, by using a custom onDrawCell method.
I really would like to add per-cell tooltips too, but I've been unsuccessful so far. I've modified something I found:
Which kind of works, but it tries to display the tooltip every px moved, making it very laggy, and it displays it without having to "pause" for a while, like you do with regular tooltips.
If anyone knows of an easier/proper way to implement this it would be much appreciated.
Thanks in advance.
I'm using a TStringGrid (has to be Delphi 7, and no 3rd party components) I've customised it to allow per-cell colouring/fonts/borders/validation etc, by using a custom onDrawCell method.
I really would like to add per-cell tooltips too, but I've been unsuccessful so far. I've modified something I found:
delphi Syntax (Toggle Plain Text)
procedure TForm1.StringGrid1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var acol, arow: integer; P : TPoint; Re: TRect; begin Re := StringGrid1.CellRect(acol, arow); P.X := Re.Bottom; P.Y := Re.Right; StringGrid1.Hint := getHint(acol, arow); Application.HintColor := clYellow; Application.ActivateHint(P); end;
Which kind of works, but it tries to display the tooltip every px moved, making it very laggy, and it displays it without having to "pause" for a while, like you do with regular tooltips.
If anyone knows of an easier/proper way to implement this it would be much appreciated.
Thanks in advance.
Last edited by TomRandall; Jun 20th, 2009 at 8:06 am.
•
•
Join Date: Jun 2009
Posts: 8
Reputation:
Solved Threads: 0
TomRandall,
A simple way is to use the OnHint event of the Application global variable. You can easily fulfil your tasks in an event handler. The effect is much better than MouseMove event.
A more general way is to build a separate thread to monitor mouse movement. You can manipulate everything in this way but it is more resource-consuming.
I think your advanced StringGrid is a very good idea. Wish you success.
A simple way is to use the OnHint event of the Application global variable. You can easily fulfil your tasks in an event handler. The effect is much better than MouseMove event.
A more general way is to build a separate thread to monitor mouse movement. You can manipulate everything in this way but it is more resource-consuming.
I think your advanced StringGrid is a very good idea. Wish you success.
•
•
Join Date: Oct 2007
Posts: 20
Reputation:
Solved Threads: 0
•
•
•
•
Hi All,
... but it tries to display the tooltip every px moved, making it very laggy, and it displays it without having to "pause" for a while, like you do with regular tooltips.
If anyone knows of an easier/proper way to implement this it would be much appreciated.
Thanks in advance.
delphi Syntax (Toggle Plain Text)
OldRow, OldCol : integer; // defined in TForm private var P : TPoint; gc: TGridCoord; begin gc := TStringGrid(Sender).MouseCoord(x, y) ; P.X := X; P.Y := Y; if (gc.x <> OldCol) or (gc.y <> OldRow) then begin OldCol := gc.x; OldRow := gc.y; StringGrid1.Hint := 'Hint for '+inttostr(OldRow); Application.HintColor := clInfobk; Application.ActivateHint(P); end;
Thanks Tom, your coding solved my problem. Perhaps the above will get your tooltip off the caffeine jitters.
•
•
Join Date: Nov 2009
Posts: 40
Reputation:
Solved Threads: 3
0
#4 31 Days Ago
Why do you need to activate the hint (Application.ActivateHint(P)) by code?
If grid.showhint is true, just changing the hint text should be ok... have you tried it without this line?
Anyhow, the application.onhint event is tricky, for a component that can have several instances on one app, using this event is tricky, as only one event handler can exists, and you need one per grid and manage it when one is freed... dificult one!
If grid.showhint is true, just changing the hint text should be ok... have you tried it without this line?
Anyhow, the application.onhint event is tricky, for a component that can have several instances on one app, using this event is tricky, as only one event handler can exists, and you need one per grid and manage it when one is freed... dificult one!
![]() |
Similar Threads
- How to make JTable cell not Editable (Java)
- Stringgrid cell color (Pascal and Delphi)
- Array cell contains the memory address of the next cell ???? (C)
- cell bil (C++)
- Cell - A NEW ERA IN COMPUTING BEGINS! (Motherboards, CPUs and RAM)
- Single Table Cell background (HTML and CSS)
- Software for PowerMac cell phone modem... (Apple Hardware)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Better way to do this Robot?
- Next Thread: how do i get shellexecute to work?
| Thread Tools | Search this Thread |





