📄 commctrl.h
字号:
#ifdef _WIN32
#define WC_LISTVIEW "SysListView32"
#else
#define WC_LISTVIEW "SysListView"
#endif
// ListView styles
//
// view type styles (we only have 16 bits to use here)
#define LVS_ICON 0x0000
#define LVS_REPORT 0x0001
#define LVS_SMALLICON 0x0002
#define LVS_LIST 0x0003
#define LVS_TYPEMASK 0x0003
// shared styles
#define LVS_SINGLESEL 0x0004
#define LVS_SHOWSELALWAYS 0x0008
#define LVS_SORTASCENDING 0x0010
#define LVS_SORTDESCENDING 0x0020
#define LVS_SHAREIMAGELISTS 0x0040
#define LVS_NOLABELWRAP 0x0080
#define LVS_AUTOARRANGE 0x0100
#define LVS_EDITLABELS 0x0200
#define LVS_NOSCROLL 0x2000
/// the fields below are reserved for style specific settings.
#define LVS_TYPESTYLEMASK 0xfc00 // the mask for all these styles
// Large icon.
#define LVS_ALIGNTOP 0x0000
#define LVS_ALIGNLEFT 0x0800
#define LVS_ALIGNMASK 0x0c00
// Report view.
#define LVS_OWNERDRAWFIXED 0x0400
#define LVS_NOCOLUMNHEADER 0x4000
#define LVS_NOSORTHEADER 0x8000
// COLORREF ListView_GetBkColor(HWND hwnd);
#define LVM_GETBKCOLOR (LVM_FIRST + 0)
#define ListView_GetBkColor(hwnd) \
(COLORREF)SendMessage((hwnd), LVM_GETBKCOLOR, 0, 0L)
// BOOL ListView_SetBkColor(HWND hwnd, COLORREF clrBk);
#define LVM_SETBKCOLOR (LVM_FIRST + 1)
#define ListView_SetBkColor(hwnd, clrBk) \
(BOOL)SendMessage((hwnd), LVM_SETBKCOLOR, 0, (LPARAM)(COLORREF)(clrBk))
// HIMAGELIST ListView_GetImageList(HWND hwnd, int iImageList);
#define LVM_GETIMAGELIST (LVM_FIRST + 2)
#define ListView_GetImageList(hwnd, iImageList) \
(HIMAGELIST)SendMessage((hwnd), LVM_GETIMAGELIST, (WPARAM)(INT)(iImageList), 0L)
#define LVSIL_NORMAL 0
#define LVSIL_SMALL 1
#define LVSIL_STATE 2
// HIMAGELIST ListView_SetImageList(HWND hwnd, HIMAGELIST himl, int iImageList);
#define LVM_SETIMAGELIST (LVM_FIRST + 3)
#define ListView_SetImageList(hwnd, himl, iImageList) \
(HIMAGELIST)(UINT)SendMessage((hwnd), LVM_SETIMAGELIST, (WPARAM)(iImageList), (LPARAM)(UINT)(HIMAGELIST)(himl))
// int ListView_GetItemCount(HWND hwnd);
#define LVM_GETITEMCOUNT (LVM_FIRST + 4)
#define ListView_GetItemCount(hwnd) \
(int)SendMessage((hwnd), LVM_GETITEMCOUNT, 0, 0L)
// ListView Item structure
#define LVIF_TEXT 0x0001 // LV_ITEM.mask flags (indicate valid fields in LV_ITEM)
#define LVIF_IMAGE 0x0002
#define LVIF_PARAM 0x0004
#define LVIF_STATE 0x0008
// State flags
#define LVIS_FOCUSED 0x0001 // LV_ITEM.state flags
#define LVIS_SELECTED 0x0002
#define LVIS_CUT 0x0004 // LVIS_MARKED
#define LVIS_DROPHILITED 0x0008
#define LVIS_OVERLAYMASK 0x0F00 // used as ImageList overlay image indexes
#define LVIS_STATEIMAGEMASK 0xF000 // client bits for state image drawing
#define LVIS_USERMASK LVIS_STATEIMAGEMASK // BUGBUG: remove me.
#define INDEXTOSTATEIMAGEMASK(i) ((i) << 12)
typedef struct _LV_ITEM
{
UINT mask; // LVIF_ flags
int iItem;
int iSubItem;
UINT state; // LVIS_ flags
UINT stateMask; // LVIS_ flags (valid bits in state)
LPSTR pszText;
int cchTextMax;
int iImage;
LPARAM lParam;
} LV_ITEM;
// Values used to cause text/image GETDISPINFO callbacks
#define LPSTR_TEXTCALLBACK ((LPSTR)-1L)
#define I_IMAGECALLBACK (-1)
// BOOL ListView_GetItem(HWND hwnd, LV_ITEM FAR* pitem);
#define LVM_GETITEM (LVM_FIRST + 5)
#define ListView_GetItem(hwnd, pitem) \
(BOOL)SendMessage((hwnd), LVM_GETITEM, 0, (LPARAM)(LV_ITEM FAR*)(pitem))
// Sets items and subitems.
//
// BOOL ListView_SetItem(HWND hwnd, const LV_ITEM FAR* pitem);
#define LVM_SETITEM (LVM_FIRST + 6)
#define ListView_SetItem(hwnd, pitem) \
(BOOL)SendMessage((hwnd), LVM_SETITEM, 0, (LPARAM)(const LV_ITEM FAR*)(pitem))
// int ListView_InsertItem(HWND hwnd, const LV_ITEM FAR* pitem);
#define LVM_INSERTITEM (LVM_FIRST + 7)
#define ListView_InsertItem(hwnd, pitem) \
(int)SendMessage((hwnd), LVM_INSERTITEM, 0, (LPARAM)(const LV_ITEM FAR*)(pitem))
// Deletes the specified item along with all its subitems.
//
// BOOL ListView_DeleteItem(HWND hwnd, int i);
#define LVM_DELETEITEM (LVM_FIRST + 8)
#define ListView_DeleteItem(hwnd, i) \
(BOOL)SendMessage((hwnd), LVM_DELETEITEM, (WPARAM)(int)(i), 0L)
// BOOL ListView_DeleteAllItems(HWND hwnd);
#define LVM_DELETEALLITEMS (LVM_FIRST + 9)
#define ListView_DeleteAllItems(hwnd) \
(BOOL)SendMessage((hwnd), LVM_DELETEALLITEMS, 0, 0L)
// UINT ListView_GetCallbackMask(HWND hwnd);
#define LVM_GETCALLBACKMASK (LVM_FIRST + 10)
#define ListView_GetCallbackMask(hwnd) \
(BOOL)SendMessage((hwnd), LVM_GETCALLBACKMASK, 0, 0)
// BOOL ListView_SetCallbackMask(HWND hwnd, UINT mask);
#define LVM_SETCALLBACKMASK (LVM_FIRST + 11)
#define ListView_SetCallbackMask(hwnd, mask) \
(BOOL)SendMessage((hwnd), LVM_SETCALLBACKMASK, (WPARAM)(UINT)(mask), 0)
// ListView_GetNextItem flags (can be used in combination)
#define LVNI_ALL 0x0000
#define LVNI_FOCUSED 0x0001 // return only focused item
#define LVNI_SELECTED 0x0002 // return only selected items
#define LVNI_CUT 0x0004 // return only marked items
#define LVNI_DROPHILITED 0x0008 // return only drophilited items
#define LVNI_ABOVE 0x0100 // return item geometrically above
#define LVNI_BELOW 0x0200 // "" below
#define LVNI_TOLEFT 0x0400 // "" to left
#define LVNI_TORIGHT 0x0800 // "" to right (NOTE: these four are
// mutually exclusive, but
// can be used with other LVNI's)
// int ListView_GetNextItem(HWND hwnd, int i, UINT flags);
#define LVM_GETNEXTITEM (LVM_FIRST + 12)
#define ListView_GetNextItem(hwnd, i, flags) \
(int)SendMessage((hwnd), LVM_GETNEXTITEM, (WPARAM)(int)(i), MAKELPARAM((flags), 0))
// ListView_FindInfo definitions
#define LVFI_PARAM 0x0001
#define LVFI_STRING 0x0002
#define LVFI_PARTIAL 0x0008
#define LVFI_WRAP 0x0020
#define LVFI_NEARESTXY 0x0040
typedef struct _LV_FINDINFO
{
UINT flags;
LPCSTR psz;
LPARAM lParam;
POINT pt; // only used for nearestxy
UINT vkDirection; // only used for nearestxy
} LV_FINDINFO;
// int ListView_FindItem(HWND hwnd, int iStart, const LV_FINDINFO FAR* plvfi);
#define LVM_FINDITEM (LVM_FIRST + 13)
#define ListView_FindItem(hwnd, iStart, plvfi) \
(int)SendMessage((hwnd), LVM_FINDITEM, (WPARAM)(int)(iStart), (LPARAM)(const LV_FINDINFO FAR*)(plvfi))
#define LVIR_BOUNDS 0
#define LVIR_ICON 1
#define LVIR_LABEL 2
#define LVIR_SELECTBOUNDS 3
// Rectangle bounding all or part of item, based on LVIR_* code. Rect is returned in view coords
// BOOL ListView_GetItemRect(HWND hwndLV, int i, RECT FAR* prc, int code);
#define LVM_GETITEMRECT (LVM_FIRST + 14)
#define ListView_GetItemRect(hwnd, i, prc, code) \
((prc)->left = (code), (BOOL)SendMessage((hwnd), LVM_GETITEMRECT, (WPARAM)(int)(i), (LPARAM)(RECT FAR*)(prc)))
// Move top-left corner of item to (x, y), specified in view rect relative coords
// (icon and small view only)
// BOOL ListView_SetItemPosition(HWND hwndLV, int i, int x, int y);
#define LVM_SETITEMPOSITION (LVM_FIRST + 15)
#define ListView_SetItemPosition(hwndLV, i, x, y) \
(BOOL)SendMessage((hwndLV), LVM_SETITEMPOSITION, (WPARAM)(int)(i), MAKELPARAM((x), (y)))
// BOOL ListView_GetItemPosition(HWND hwndLV, int i, POINT FAR* ppt);
#define LVM_GETITEMPOSITION (LVM_FIRST + 16)
#define ListView_GetItemPosition(hwndLV, i, ppt) \
(BOOL)SendMessage((hwndLV), LVM_GETITEMPOSITION, (WPARAM)(int)(i), (LPARAM)(POINT FAR*)(ppt))
// Get column width of string
// int ListView_GetStringWidth(HWND hwndLV, LPCSTR psz);
#define LVM_GETSTRINGWIDTH (LVM_FIRST + 17)
#define ListView_GetStringWidth(hwndLV, psz) \
(int)SendMessage((hwndLV), LVM_GETSTRINGWIDTH, 0, (LPARAM)(LPCSTR)(psz))
// Hit test item. Returns item at (x,y), or -1 if not on an item.
// Combination of LVHT_ values *pflags, indicating where the cursor
// is relative to edges of ListView window (above, below, right, left)
// or whether (x, y) is over icon, label, or inside window but not on item.
// int ListView_HitTest(HWND hwndLV, LV_HITTESTINFO FAR* pinfo);
// ItemHitTest flag values
#define LVHT_NOWHERE 0x0001
#define LVHT_ONITEMICON 0x0002
#define LVHT_ONITEMLABEL 0x0004
#define LVHT_ONITEMSTATEICON 0x0008
#define LVHT_ONITEM (LVHT_ONITEMICON | LVHT_ONITEMLABEL | LVHT_ONITEMSTATEICON)
#define LVHT_ABOVE 0x0008
#define LVHT_BELOW 0x0010
#define LVHT_TORIGHT 0x0020
#define LVHT_TOLEFT 0x0040
typedef struct _LV_HITTESTINFO
{
POINT pt; // in: client coords
UINT flags; // out: LVHT_ flags
int iItem; // out: item
} LV_HITTESTINFO;
// int ListView_HitTest(HWND hwndLV, LV_HITTESTINFO FAR* pinfo);
#define LVM_HITTEST (LVM_FIRST + 18)
#define ListView_HitTest(hwndLV, pinfo) \
(int)SendMessage((hwndLV), LVM_HITTEST, 0, (LPARAM)(LV_HITTESTINFO FAR*)(pinfo))
// Return view rectangle, relative to window
// BOOL ListView_GetViewRect(HWND hwndLV, RECT FAR* prcVis);
// Scroll an item into view if not wholly or partially visible
// BOOL ListView_EnsureVisible(HWND hwndLV, int i, BOOL fPartialOK);
#define LVM_ENSUREVISIBLE (LVM_FIRST + 19)
#define ListView_EnsureVisible(hwndLV, i, fPartialOK) \
(BOOL)SendMessage((hwndLV), LVM_ENSUREVISIBLE, (WPARAM)(int)(i), MAKELPARAM((fPartialOK), 0))
// Scroll listview -- offsets origin of view rectangle by dx, dy
// BOOL ListView_Scroll(HWND hwndLV, int dx, int dy);
#define LVM_SCROLL (LVM_FIRST + 20)
#define ListView_Scroll(hwndLV, dx, dy) \
(BOOL)SendMessage((hwndLV), LVM_SCROLL, (WPARAM)(int)dx, (LPARAM)(int)dy)
// Force eventual redraw of range of items (redraw doesn't occur
// until WM_PAINT processed -- call UpdateWindow() after to redraw right away)
// BOOL ListView_RedrawItems(HWND hwndLV, int iFirst, int iLast);
#define LVM_REDRAWITEMS (LVM_FIRST + 21)
#define ListView_RedrawItems(hwndLV, iFirst, iLast) \
(BOOL)SendMessage((hwndLV), LVM_REDRAWITEMS, (WPARAM)(int)iFirst, (LPARAM)(int)iLast)
// Arrange style
#define LVA_DEFAULT 0x0000
#define LVA_ALIGNLEFT 0x0001
#define LVA_ALIGNTOP 0x0002
#define LVA_SNAPTOGRID 0x0005
// Arrange icons according to LVA_* code
// BOOL ListView_Arrange(HWND hwndLV, UINT code);
#define LVM_ARRANGE (LVM_FIRST + 22)
#define ListView_Arrange(hwndLV, code) \
(BOOL)SendMessage((hwndLV), LVM_ARRANGE, (WPARAM)(UINT)(code), 0L)
// Begin editing the label of a control. Implicitly selects and focuses
// item. i == -1 to cancel.
// HWND ListView_EditLabel(HWND hwndLV, int i);
#define LVM_EDITLABEL (LVM_FIRST + 23)
#define ListView_EditLabel(hwndLV, i) \
(HWND)SendMessage((hwndLV), LVM_EDITLABEL, (WPARAM)(int)(i), 0L)
// Return edit control being used for editing. Subclass OK, but
// don't destroy. Will be destroyed when editing is finished.
//HWND ListView_GetEditControl(HWND hwndLV);
#define LVM_GETEDITCONTROL (LVM_FIRST + 24)
#define ListView_GetEditControl(hwndLV) \
(HWND)SendMessage((hwndLV), LVM_GETEDITCONTROL, 0, 0L)
typedef struct _LV_COLUMN
{
UINT mask;
int fmt;
int cx;
LPSTR pszText;
int cchTextMax;
int iSubItem; // subitem to display
} LV_COLUMN;
// LV_COLUMN mask values
#define LVCF_FMT 0x0001
#define LVCF_WIDTH 0x0002
#define LVCF_TEXT 0x0004
#define LVCF_SUBITEM 0x0008
// Column format codes
#define LVCFMT_LEFT 0
#define LVCFMT_RIGHT 1
#define LVCFMT_CENTER 2
#define LVCFMT_JUSTIFYMASK 0x0003
// Set/Query column info
// BOOL ListView_GetColumn(HWND hwndLV, int iCol, LV_COLUMN FAR* pcol);
#define LVM_GETCOLUMN (LVM_FIRST + 25)
#define ListView_GetColumn(hwnd, iCol, pcol) \
(BOOL)SendMessage((hwnd), LVM_GETCOLUMN, (WPARAM)(int)(iCol), (LPARAM)(LV_COLUMN FAR*)(pcol))
// BOOL ListView_SetColumn(HWND hwndLV, int iCol, LV_COLUMN FAR* pcol);
#define LVM_SETCOLUMN (LVM_FIRST + 26)
#define ListView_SetColumn(hwnd, iCol, pcol) \
(BOOL)SendMessage((hwnd), LVM_SETCOLUMN, (WPARAM)(int)(iCol), (LPARAM)(const LV_COLUMN FAR*)(pcol))
// insert/delete report view column
// int ListView_InsertColumn(HWND hwndLV, int iCol, const LV_COLUMN FAR* pcol);
#define LVM_INSERTCOLUMN (LVM_FIRST + 27)
#define ListView_InsertColumn(hwnd, iCol, pcol) \
(int)SendMessage((hwnd), LVM_INSERTCOLUMN, (WPARAM)(int)(iCol), (LPARAM)(const LV_COLUMN FAR*)(pcol))
// BOOL ListView_DeleteColumn(HWND hwndLV, int iCol);
#define LVM_DELETECOLUMN (LVM_FIRST + 28)
#define ListView_DeleteColumn(hwnd, iCol) \
(BOOL)SendMessage((hwnd), LVM_DELETECOLUMN, (WPARAM)(int)(iCol), 0)
#define LVM_GETCOLUMNWIDTH (LVM_FIRST + 29)
#define ListView_GetColumnWidth(hwnd, iCol) \
(int)SendMessage((hwnd), LVM_GETCOLUMNWIDTH, (WPARAM)(int)(iCol), 0)
#define LVSCW_AUTOSIZE -1
#define LVSCW_AUTOSIZE_USEHEADER -2
#define LVM_SETCOLUMNWIDTH (LVM_FIRST + 30)
#define ListView_SetColumnWidth(hwnd, iCol, cx) \
(BOOL)SendMessage((hwnd), LVM_SETCOLUMNWIDTH, (WPARAM)(int)(iCol), MAKELPARAM((cx), 0))
// HIMAGELIST ListView_Cre
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -