wwdbgrid, showcellhint and hintpause

291 views
Skip to first unread message

r...@ssv.dk

unread,
Nov 9, 2015, 4:10:13 AM11/9/15
to woll2woll.infopower
How do I manage to delay hints in wwdbgrid ?
dgShowCellHint is on. Hints is showing immediately. Hintpause is not respected.
I am using infopower 2010/Delphi 2010.

roy....@gmail.com

unread,
Nov 10, 2015, 11:21:34 AM11/10/15
to r...@ssv.dk, woll2woll...@googlegroups.com
Cell level hints are designed to be immediate on the mouse move. I will log your request for a delayed cell hint. Only the component hint is delayed.

If you really need this, you can customize the application’s hint property via the grid’s OnMouseMove. Then it will respect your application’s hint timer, etc. Here is an example. Note to set your ShowHint to true for the grid and disable dgCellHints for this to work.

Put the following in your form’s implementation section.

type TwwHintGrid = class(TwwDBGrid);
var
  lastx :integer = 0;
  lasty : integer = 0;

Then put the following code in your grid’s OnMouseMove.

procedure TBtnGridForm.wwDBGrid1MouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
var
  PriorRow: Integer;
  indicatoroffset, titleoffset: Integer;
  coord: TGridCoord;
begin
  coord:= TwwDBGrid(Sender).MouseCoord(X, Y);
  begin
    if ((coord.X <> lastx) or (coord.Y <> lasty)) then
    begin
      application.cancelhint;
      indicatoroffset := 0;
      titleoffset := 0;
      if TwwDBGridOption.dgIndicator in TwwDBGrid(Sender).Options then
        indicatoroffset := 1;
      if TwwDBGridOption.dgTitles in TwwDBGrid(Sender).Options then
        titleoffset := 1;
      if (coord.Y >= titleoffset) and (coord.X >= indicatoroffset) then // data cell
      begin
        PriorRow := TwwDBGrid(Sender).GetActiveRow;
        TwwHintGrid(Sender).DataLink.ActiveRecord := coord.Y - titleoffset;
        if coord.X - indicatoroffset < TwwDBGrid(Sender).GetColCount then
          TwwHintGrid(Sender).Hint := TwwDBGrid(Sender).Fields[coord.X - indicatoroffset].asString;
        TwwHintGrid(Sender).DataLink.ActiveRecord := PriorRow;
      end
      else if (coord.Y < titleoffset) and (coord.X>= indicatorOffset) then // Hint for titles
      begin
          TwwHintGrid(Sender).Hint := TwwDBGrid(Sender).Fields[coord.X-IndicatorOffset].DisplayLabel
      end
      else if (coord.x < indicatorOffset) and (coord.Y <TitleOffset) then // indicator column do clear hint
      begin
          // Does not work if you attached an indicator button
          // In that case, just attach your hint to the indicator button's hint/showhint properties
          TwwHintGrid(Sender).Hint := 'Top Left Hint'
      end
      else begin // default to blank if none of the above
          TwwHintGrid(Sender).Hint := ''
      end;

      lastx := coord.X;
      lasty := coord.Y;
    end;
  end
end;


Roy Woll
--
You received this message because you are subscribed to the Google Groups "woll2woll.infopower" group.
To unsubscribe from this group and stop receiving emails from it, send an email to woll2wollinfopo...@googlegroups.com.
Visit this group at http://groups.google.com/group/woll2wollinfopower.
To view this discussion on the web visit https://groups.google.com/d/msgid/woll2wollinfopower/b018d88b-f06f-47e5-97a3-9a2691f5d87c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

r...@ssv.dk

unread,
Nov 11, 2015, 10:48:17 AM11/11/15
to woll2woll.infopower, r...@ssv.dk
Thank you !
Especially for all the details calculating actual Row/Field :-)
Works fine.
Reply all
Reply to author
Forward
0 new messages