Set the header icon for listview
Author: zswangII / 9CBS Updated: legume Source: Unknown Last update: 2004-06-11 Submission-mail: jc@ddvip.net (* // Title: Set ListView header Icon Description: Can be used to make modifications sort icon design : Zswang support: wjhu111@21cn.com date: 2004-03-25 // *) uses CommCtrl; function ListViewHeaderImages (mListView: TListView; mImages: TImageList): Boolean; varvHandle: THandle; beginResult: = False; if not Assigned ( mListView) then Exit; vHandle: = ListView_GetHeader (mListView.Handle); if Assigned (mImages) thenHeader_SetImageList (vHandle, mImages.Handle) else Header_SetImageList (vHandle, 0); Result: = True; end; {ListViewHeaderImages} function ListColumnImageIndex (mColumn : TListColumn; mImageIndex: Integer; mRight: Boolean = True): Boolean; varvHandle: THandle; vHDItem: THDItem; beginResult: = False; if not Assigned (mColumn) then Exit; vHandle: = ListView_GetHeader (TListView (mColumn.Collection.Owner ) .Handle); FillChar (vHDItem, SizeOf (vHDItem), 0); Header_GetItem (vHandle, mColumn.Index, vHDItem); if mImageIndex <0 then beginvHDItem.Mask: = HDI_FORMAT; vHDItem.fmt: = HDF_STRING; end else beginvHDItem .Mask: = HDI_ IMAGE or HDI_FORMAT; vHDItem.iImage: = mImageIndex; vHDItem.fmt: = HDF_STRING or HDF_IMAGE or (HDF_BITMAP_ON_RIGHT * Ord (mRight)); end; Header_SetItem (vHandle, mColumn.Index, vHDItem); end; {ListColumnImageIndex} // Exampleprocedure TForm1.ListView1ColumnClick (Sender: TObject; Column: TListColumn); {$ J } const vIndex: Integer = 0; {$ J-} varI: Integer; beginfor I: = 0 to TListView (Sender) .Columns.Count - 1 doListColumnImageIndex (TListView (sender) .COLUMNS [I], -1); if abs (vindex) = column.index 1 thenvindex: = -vindexelse vindex: = column.index 1; ListColumnImageIndex (Column, ORD (VINDEX> 0) END;