delphi - How to show DBGrid.Hint when hovering with the mouse on a cell? -
while following code correctly set form1.caption text of cell mouse over, not display dbgrid.hint unless click on cell.
what wrong picture?
type thackgrid = class(tdbgrid); // expose protected datalink property procedure tform1.dbgrid1mousemove(sender: tobject; shift: tshiftstate; x, y: integer); var cell: tgridcoord; actrec: integer; begin cell := dbgrid1.mousecoord(x, y); if dgindicator in dbgrid1.options dec(cell.x); if dgtitles in dbgrid1.options dec(cell.y); if thackgrid(dbgrid1).datalink.active , (cell.x >= 0) , (cell.y >= 0) begin actrec := thackgrid(dbgrid1).datalink.activerecord; try thackgrid(dbgrid1).datalink.activerecord := cell.y; caption := dbgrid1.columns[cell.x].field.asstring; // form1.caption shows fine! dbgrid.hint := dbgrid1.columns[cell.x].field.asstring; // <== hint shows when click cell! thackgrid(dbgrid1).datalink.activerecord := actrec; end; end; end;
call application.activatehint
desired coordinates hint, e.g.
procedure changehint(c: tcontrol; const hint: string; p: tpoint); var oldhint: string; begin oldhint := c.hint; if hint <> oldhint begin c.hint := hint; application.activatehint(p); end; end; procedure tform3.dbgrid1mousemove(sender: tobject; shift: tshiftstate; x, y: integer); begin ... changehint(tdbgrid(sender), yourintendedhinttext, tdbgrid(sender).clienttoscreen(point(x, y))); .... end;
Comments
Post a Comment