Author: Jonas Bilinkevicius
Can you underline the caption of a ListView Item?
Answer:
To draw an Underline on a Listview Caption the same like the HotTrack function in
Delphi 6 in Delphi 3 you must call an API function.
In the Uses Clausse inpelement the CommCtrl unit.
Then you set the following code in the MouseMove property of your ListView.
1 2 procedure TfrmMain.lvwMainMouseMove(Sender: TObject; Shift: TShiftState; X,
3 Y: Integer);
4 const5 LVS_EX_UNDERLINEHOT = $00000800;
6 LVS_EX_INFOTIP = $00000400;
7 var8 AItem: TListItem;
9 Styles: DWord;
10 begin11 //This line is a VCL Bugfix for the ListView12 Styles := LVS_EX_INFOTIP;
13 AItem := lvwMain.GetItemAt(X, Y);
14 ifnot Assigned(AItem) then15 begin16 lvwMain.Cursor := crArrow;
17 end18 else19 begin20 lvwMain.Cursor := crHandPoint;
21 Styles := Trunc(Styles + LVS_EX_UNDERLINEHOT - LVS_EX_CHECKBOXES -
22 LVS_EX_FULLROWSELECT);
23 ListView_SetExtendedListViewStyle(lvwMain.Handle, Styles);
24 end;
25 end;
When you goes with your mouse over an ListView Item there will be an underline
drawed under the caption of the Item.
Because the value that exists in the Styles variabele allso enables checkboxes and
rowselect add the following lines under the Styles lines and above the
SetExtendedListViewStyle.
26 Styles := Styles - LVS_EX_CHECKBOXES;
27 Styles := Styles - LVS_EX_TRACKSELECT;
This will fix the bug of the Checkboxes and TrackSelecting.