2007. október 4., csütörtök
How to draw an underline on a Listview Caption
Problem/Question/Abstract:
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.
procedure TfrmMain.lvwMainMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
const
LVS_EX_UNDERLINEHOT = $00000800;
LVS_EX_INFOTIP = $00000400;
var
AItem: TListItem;
Styles: DWord;
begin
//This line is a VCL Bugfix for the ListView
Styles := LVS_EX_INFOTIP;
AItem := lvwMain.GetItemAt(X, Y);
if not Assigned(AItem) then
begin
lvwMain.Cursor := crArrow;
end
else
begin
lvwMain.Cursor := crHandPoint;
Styles := Trunc(Styles + LVS_EX_UNDERLINEHOT - LVS_EX_CHECKBOXES -
LVS_EX_FULLROWSELECT);
ListView_SetExtendedListViewStyle(lvwMain.Handle, Styles);
end;
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.
Styles := Styles - LVS_EX_CHECKBOXES;
Styles := Styles - LVS_EX_TRACKSELECT;
This will fix the bug of the Checkboxes and TrackSelecting.
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése