[SOLVED]DBGrid title mouse over event lazarus / 16-Databases ---------------------------------------------------------------------- johnmc · 2019-03-30 18:13 I have a DBGrid and would like to highlight which column headings are clickable by using something like an onmouseover event. There dosen't seem to be anything simple. One posibility seems to be to use the OnMouseMove and the determine the co-ordinates of the mouse in terms of the grid X and Y ( Col and Row) position. I have yet to try this. Also I found there is an dgTitleHotTrack option does anyone know where this is documented or how to use it? regards John ---------------------------------------------------------------------- howardpc · 2019-03-30 19:24 Quote from: johnmc on March 30, 2019, 07:13:43 pmAlso I found there is an dgTitleHotTrack option does anyone know where this is documented or how to use it? You use it by including dgHeaderHotTrack in Options, and setting FixedHotColor to your desired colour. However, this simply highlights the column header title when the mouse hovers over it (whether you have defined column items or not), and you are looking for something more than this I think, for which you would have to write an OnMouseMove handler. ---------------------------------------------------------------------- jesusr · 2019-03-30 19:29 You mean dgHeaderHotTracking, it does just what you want, it highlights  the column header where the mouse is at the moment. Now you want something more specific, some column header should be highlighted and some not. I think the easiest solution is what you already mention. You need to cheat a little, you have to find over what column you are, check if this column is clickable and if it's so, do nothing, but if it's not, change the FixedHotColor (which is the color used to draw the 'hot look'). Something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure formXXXXX.dbgridMouseMove(Sender: TObject; Shift: TShiftState; X,  Y: Integer); var  aCol, aRow: Longint;begin  dbgrid.MouseToCell(x, y, aCol, aRow);  if Unclickable(aCol) then dbgrid.FixedHotColor := dbgrid.FixedColor  else             dbgrid.FixedHotColor := FOldFixedHotColor;end;   Note that this will work only if the grid titleStyle property is different from tsNative because that internally uses OS theme drawing and not custom drawing. FOldFixedHotColor:=dbgrid.FixedHotColor at form create for example. ---------------------------------------------------------------------- sstvmaster · 2019-03-30 19:34 Or also this with tsNative: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,  Y: Integer);var  Col,  Row : Integer;begin  Col := DBGrid1.MouseCoord(X, Y).X;  Row := DBGrid1.MouseCoord(X, Y).Y;   if (Col > 0) and (Col <= DBGrid1.Columns.Count) then  begin     // 1 is needed column to highlight    if Col = 1 then      DBGrid1.Options := DBGrid1.Options + [dgHeaderHotTracking]    else      DBGrid1.Options := DBGrid1.Options - [dgHeaderHotTracking];   end;end; ---------------------------------------------------------------------- jesusr · 2019-03-30 19:51 Quote from: sstvmaster on March 30, 2019, 08:34:49 pmOr also this with tsNative: Nice! and it will not require additional variable for preserving the design time fixed hot color. Although it will queue redrawings as crazy but should not matter too much ---------------------------------------------------------------------- johnmc · 2019-03-31 10:26 Thanks for all the input. I will give things a try and see whether I can get the desired results. John ---------------------------------------------------------------------- johnmc · 2019-03-31 14:26 sstvmaster, that work a treat. I did have to change the default TitleStyle from tsLazarus to tsNative. The highlighting color is brighter when using tsNative. Regards John ---------------------------------------------------------------------- sstvmaster · 2019-03-31 14:46 You can also use "tsStandard or tsLazarus" and change the "FixedHotColor" to a color you want. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     if (Col=1) or (Col=3) then    begin      DBGrid1.FixedHotColor := clLime; // <-- hover color      DBGrid1.Options := DBGrid1.Options + [dgHeaderHotTracking];    end    else    begin      DBGrid1.Options := DBGrid1.Options - [dgHeaderHotTracking];      DBGrid1.FixedHotColor := cl3DLight; // <-- std. color    end;