📄 extlistview.pas
字号:
{$I DFS.INC} { Standard defines for all Delphi Free Stuff components }
{.$DEFINE DFS_DEBUG}
{.$DEFINE DFS_TRY_BACKGROUND_IMAGE}
{------------------------------------------------------------------------------}
{ TdfsExtListView v3.72 }
{------------------------------------------------------------------------------}
{ A list view control that enables access to the new style types provieded }
{ by the updated list view control. The updated list view is provided in }
{ the COMCTL32.DLL file that comes with Microsoft's new internet software. }
{ }
{ Copyright 1998-2001, Brad Stowers. All Rights Reserved. }
{ }
{ Copyright: }
{ All Delphi Free Stuff (hereafter "DFS") source code is copyrighted by }
{ Bradley D. Stowers (hereafter "author"), and shall remain the exclusive }
{ property of the author. }
{ }
{ Distribution Rights: }
{ You are granted a non-exlusive, royalty-free right to produce and distribute }
{ compiled binary files (executables, DLLs, etc.) that are built with any of }
{ the DFS source code unless specifically stated otherwise. }
{ You are further granted permission to redistribute any of the DFS source }
{ code in source code form, provided that the original archive as found on the }
{ DFS web site (http://www.delphifreestuff.com) is distributed unmodified. For }
{ example, if you create a descendant of TDFSColorButton, you must include in }
{ the distribution package the colorbtn.zip file in the exact form that you }
{ downloaded it from http://www.delphifreestuff.com/mine/files/colorbtn.zip. }
{ }
{ Restrictions: }
{ Without the express written consent of the author, you may not: }
{ * Distribute modified versions of any DFS source code by itself. You must }
{ include the original archive as you found it at the DFS site. }
{ * Sell or lease any portion of DFS source code. You are, of course, free }
{ to sell any of your own original code that works with, enhances, etc. }
{ DFS source code. }
{ * Distribute DFS source code for profit. }
{ }
{ Warranty: }
{ There is absolutely no warranty of any kind whatsoever with any of the DFS }
{ source code (hereafter "software"). The software is provided to you "AS-IS", }
{ and all risks and losses associated with it's use are assumed by you. In no }
{ event shall the author of the softare, Bradley D. Stowers, be held }
{ accountable for any damages or losses that may occur from use or misuse of }
{ the software. }
{ }
{ Support: }
{ Support is provided via the DFS Support Forum, which is a web-based message }
{ system. You can find it at http://www.delphifreestuff.com/discus/ }
{ All DFS source code is provided free of charge. As such, I can not guarantee }
{ any support whatsoever. While I do try to answer all questions that I }
{ receive, and address all problems that are reported to me, you must }
{ understand that I simply can not guarantee that this will always be so. }
{ }
{ Clarifications: }
{ If you need any further information, please feel free to contact me directly.}
{ This agreement can be found online at my site in the "Miscellaneous" section.}
{------------------------------------------------------------------------------}
{ The lateset version of my components are always available on the web at: }
{ http://www.delphifreestuff.com/ }
{ See ELV.txt for notes, known issues, and revision history. }
{------------------------------------------------------------------------------}
{ Date last modified: June 28, 2001 }
{------------------------------------------------------------------------------}
unit ExtListView;
interface
{$IFNDEF DFS_WIN32}
ERROR! This unit only available for Delphi 2.0 or higher!!!
{$ENDIF}
uses
Windows, Messages, Classes, Controls, ComCtrls, CommCtrl, SysUtils, Graphics,
{$IFDEF DFS_COMPILER_4_UP}
ImgList,
{$ENDIF}
StdCtrls, Menus, EnhListView;
const
{ This shuts up C++Builder 3 about the redefiniton being different. There
seems to be no equivalent in C1. Sorry. }
{$IFDEF DFS_CPPB_3_UP}
{$EXTERNALSYM DFS_COMPONENT_VERSION}
{$ENDIF}
DFS_COMPONENT_VERSION = 'TdfsExtListView v3.72';
// Setting a subitem image (lvxSubItemImages ExtendStyle) to -1 does not
// properly clear the image for the subitem. The current COMCTL32.DLL
// implementation does not seem to store this value and instead it gets a
// random value assigned to it. The work-around that I have found is to set
// the index to a value that does not exist in the image list. To make this
// a bit easier, I have declared this constant. Assigning this value to
// SubItem_ImageIndex[itemindex] will clear the image from the subitem as long
// as your image list does not have more than 2,147,483,646 images in it. :)
const
ELV_NO_SUBITEM_IMAGE = MAXINT - 1;
// C3 and D4 CommCtrl.pas have almost everything we need
{$IFDEF DFS_CPPB_3_UP}
{$DEFINE DFS_C3D4COMMCTRL}
{$ELSE} {$IFDEF DFS_DELPHI_4_UP}
{$DEFINE DFS_C3D4COMMCTRL}
{$ENDIF} {$ENDIF}
{$IFNDEF DFS_C3D4COMMCTRL}
type
TLVDispInfo = TLVDispInfoA; // Borland forgot this one in D2, D3 & C1s
{$ENDIF}
{$IFNDEF DFS_C3D4COMMCTRL}
const
LVIF_INDENT = $0010;
LVIF_NORECOMPUTE = $0800;
{.$IFDEF DFS_DELPHI_2}
{ These are in COMMCTRL unit
LVCF_FMT = $0001;
LVCF_WIDTH = $0002;
LVCF_TEXT = $0004;
LVCF_SUBITEM = $0008;
}
{.$ENDIF}
LVCF_IMAGE = $0010;
LVCF_ORDER = $0020;
{.$IFDEF DFS_DELPHI_2}
{ These are in COMMCTRL unit
LVCFMT_LEFT = $0000;
LVCFMT_RIGHT = $0001;
LVCFMT_CENTER = $0002;
LVCFMT_JUSTIFYMASK = $0003;
}
{.$ENDIF}
LVCFMT_IMAGE = $0800; // Item displays an image from an image list.
LVCFMT_BITMAP_ON_RIGHT = $1000; // Image appears to right of Text.
LVCFMT_COL_HAS_IMAGES = $8000; // Undocumented.
LVIS_ACTIVATING = $0020;
{$ENDIF}
type
PLVItemEx = ^TLVItemEx;
TLVItemEx = packed record
mask: UINT;
iItem: Integer;
iSubItem: Integer;
state: UINT;
stateMask: UINT;
pszText: PAnsiChar;
cchTextMax: Integer;
iImage: Integer;
lParam: LPARAM;
iIndent: integer;
end;
PLVDispInfoEx = ^TLVDispInfoEx;
TLVDispInfoEx = packed record
hdr: TNMHDR;
item: TLVItemEx;
end;
TLVColumnEx = packed record
mask: UINT;
fmt: Integer;
cx: Integer;
pszText: PAnsiChar;
cchTextMax: Integer;
iSubItem: Integer;
iImage: integer; // New
iOrder: integer; // New
end;
// These functions already exist, and there is no way to override them, so I'll
// just rename them and you can use them as best you can.
function ListView_GetColumnEx(LVWnd: HWND; iCol: Integer;
var pcol: TLVColumnEx): Bool;
function ListView_SetColumnEx(LVWnd: HWnd; iCol: Integer;
const pcol: TLVColumnEx): Bool;
function ListView_InsertColumnEx(LVWnd: HWND; iCol: Integer;
const pcol: TLVColumnEx): Integer;
{$IFNDEF DFS_C3D4COMMCTRL}
const
LVM_GETHEADER = LVM_FIRST + 31;
function ListView_GetHeader(LVWnd: HWnd): HWnd;
{$ENDIF}
{$IFNDEF DFS_COMPILER_3_UP}
const
LVM_SETICONSPACING = LVM_FIRST + 53;
// -1 for cx and cy means we'll use the default (system settings)
// 0 for cx or cy means use the current setting (allows you to change just one
// param)
function ListView_SetIconSpacing(LVWnd: HWnd; cx, cy: integer): DWORD;
const
LVS_EX_GRIDLINES = $00000001; // Report mode only.
LVS_EX_SUBITEMIMAGES = $00000002; // Report mode only.
LVS_EX_CHECKBOXES = $00000004;
LVS_EX_TRACKSELECT = $00000008;
LVS_EX_HEADERDRAGDROP = $00000010; // Report mode only.
LVS_EX_FULLROWSELECT = $00000020; // Report mode only.
LVS_EX_ONECLICKACTIVATE = $00000040;
LVS_EX_TWOCLICKACTIVATE = $00000080;
LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54; // optional wParam = mask
function ListView_SetExtendedListViewStyle(LVWnd: HWnd; ExStyle: LPARAM): DWORD;
const
LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55;
function ListView_GetExtendedListViewStyle(LVWnd: HWnd): DWORD;
{$ENDIF}
(* These were already defined in everything...
const
LVIR_BOUNDS = 0;
LVIR_ICON = 1;
LVIR_LABEL = 2;
LVIR_SELECTBOUNDS = 3;
*)
{$IFDEF DFS_COMPILER_2}
const
LVM_GETSUBITEMRECT = LVM_FIRST + 56;
function ListView_GetSubItemRect(LVWnd: HWnd; ParentItem, SubItem,
Code: integer; var Rect: TRect): boolean;
const
LVM_SUBITEMHITTEST = LVM_FIRST + 57;
{$ENDIF}
{$IFNDEF DFS_C3D4COMMCTRL}
const
LVS_EX_FLATSB = $00000100;
LVS_EX_REGIONAL = $00000200;
LVS_EX_INFOTIP = $00000400;
LVS_EX_UNDERLINEHOT = $00000800;
LVS_EX_UNDERLINECOLD = $00001000;
LVS_EX_MULTIWORKAREAS = $00002000;
// Pass the LVS_EX_* styles you want to modify in Mask and ExStyle will apply
// only to those. Others will be left in current state. For example, if you
// pass LVS_EX_FULLROWSELECT for Mask and 0 for ExStyle, the
// LVS_EX_FULLROWSELECT style will be cleared, but all other styles will remain
// the same.
function ListView_SetExtendedListViewStyleEx(LVWnd: HWnd; Mask: DWord;
ExStyle: LPARAM): DWORD;
{$ENDIF}
// Should be COMPILER not DELPHI, but can't get Builder 5 to compile it.
{$IFNDEF DFS_CPPB}
{$IFNDEF DFS_DELPHI_7_UP}
const
LVS_EX_LABELTIP = $00004000; // Requires ComCtl32.DLL v5.80
{$ENDIF}
{$ENDIF}
(*
{$IFNDEF DFS_COMPILER_7_UP}
const
LVS_EX_LABELTIP = $00004000; // Requires ComCtl32.DLL v5.80
{$ENDIF}
*)
{$IFNDEF DFS_C3D4COMMCTRL}
// C3 & D4 users don't need this because their COMMCTRL.PAS file has it right
// and they can simply use the existing TLVHitTestInfo and
// ListView_SubItemHitTest()
type
PLVHitTestInfoEx = ^TLVHitTestInfoEx;
TLVHitTestInfoEx = packed record
pt: TPoint;
flags: UINT;
iItem: integer;
iSubItem: integer;
end;
function ListView_SubItemHitTestEx(LVWnd: HWnd;
var HitTestInfo: TLVHitTestInfoEx): integer;
{$ENDIF}
{$IFNDEF DFS_COMPILER_3_UP}
const
LVM_SETCOLUMNORDERARRAY = LVM_FIRST + 58;
function ListView_SetColumnOrderArray(LVWnd: HWnd; Count: integer;
IntArray: PIntArray): boolean;
const
LVM_GETCOLUMNORDERARRAY = LVM_FIRST + 59;
function ListView_GetColumnOrderArray(LVWnd: HWnd; Count: integer;
IntArray: PIntArray): boolean;
const
LVM_SETHOTITEM = LVM_FIRST + 60;
function ListView_SetHotItem(LVWnd: HWnd; Item: integer): integer;
const
LVM_GETHOTITEM = LVM_FIRST + 61;
function ListView_GetHotItem(LVWnd: HWnd): integer;
const
LVM_SETHOTCURSOR = LVM_FIRST + 62;
function ListView_SetHotCursor(LVWnd: HWnd; Cursor: HCursor): HCursor;
const
LVM_GETHOTCURSOR = LVM_FIRST + 63;
function ListView_GetHotCursor(LVWnd: HWnd): HCursor;
const
LVM_APPROXIMATEVIEWRECT = LVM_FIRST + 64;
function ListView_ApproximateViewRect(LVWnd: HWnd; Width, Height,
Count: integer): DWORD;
const
LVM_SETWORKAREA = LVM_FIRST + 65;
function ListView_SetWorkArea(LVWnd: HWnd; const Rect: TRect): boolean;
function ListView_GetCheckState(LVWnd: HWnd; Index: UINT): boolean;
procedure ListView_SetCheckState(LVWnd: HWnd; Index: UINT; Checked: boolean);
{$ENDIF}
{$IFNDEF DFS_C3D4COMMCTRL}
const
LVSICF_NOINVALIDATEALL = $00000001;
LVSICF_NOSCROLL = $00000002;
procedure ListView_SetItemCountEx(LVWnd: HWnd; Items: integer; Flags: DWORD);
{$ENDIF}
{$IFNDEF DFS_COMPILER_3_UP}
const
// New list view style flags.
LVS_OWNERDATA = $1000; // Specifies a "virtual" control.
// New notification messages.
LVN_ODCACHEHINT = LVN_FIRST-13;
LVN_ODFINDITEMA = LVN_FIRST-52;
LVN_ODFINDITEMW = LVN_FIRST-79;
LVN_ODFINDITEM = LVN_ODFINDITEMA;
{$ENDIF}
{$IFNDEF DFS_C3D4COMMCTRL}
const
LVN_ITEMACTIVATE = LVN_FIRST-14;
LVN_ODSTATECHANGED = LVN_FIRST-15;
LVN_MARQUEEBEGIN = LVN_FIRST-56;
{$ENDIF}
{$IFNDEF DFS_COMPILER_3_UP}
type
PNMCacheHint = ^TNMCacheHint;
TNMCacheHint = packed record
hdr: TNMHDR;
iFrom: integer;
iTo: integer;
end;
PNMFindItem = ^TNMFindItem;
TNMFindItem = packed record
hdr: TNMHDR;
iStart: integer;
lvif: TLVFindInfo;
end;
{$ENDIF}
type
PNMODStateChange = ^TNMODStateChange;
TNMODStateChange = packed record
hdr: TNMHDR;
iFrom: integer;
iTo: integer;
uNewState: UINT;
uOldState: UINT;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -