📄 commctrl.h
字号:
/*****************************************************************************\
* *
* commctrl.h - - Interface for the Windows Common Controls *
* *
* Version 1.0 *
* *
* Copyright (c) 1991-1995, Microsoft Corp. All rights reserved. *
* *
\*****************************************************************************/
/*REVIEW: this stuff needs Windows style in many places; find all REVIEWs. */
#ifndef _INC_COMMCTRL
#define _INC_COMMCTRL
#ifndef NOUSER
//
// Define API decoration for direct importing of DLL references.
//
#ifndef WINCOMMCTRLAPI
#if !defined(_COMCTL32_) && defined(_WIN32)
#define WINCOMMCTRLAPI DECLSPEC_IMPORT
#else
#define WINCOMMCTRLAPI
#endif
#endif // WINCOMMCTRLAPI
//
// For compilers that don't support nameless unions
//
#ifndef DUMMYUNIONNAME
#ifdef NONAMELESSUNION
#define DUMMYUNIONNAME u
#define DUMMYUNIONNAME2 u2
#define DUMMYUNIONNAME3 u3
#else
#define DUMMYUNIONNAME
#define DUMMYUNIONNAME2
#define DUMMYUNIONNAME3
#endif
#endif // DUMMYUNIONNAME
#ifdef _WIN32
#include <pshpack1.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Users of this header may define any number of these constants to avoid
* the definitions of each functional group.
* NOTOOLBAR Customizable bitmap-button toolbar control.
* NOUPDOWN Up and Down arrow increment/decrement control.
* NOSTATUSBAR Status bar and header bar controls.
* NOMENUHELP APIs to help manage menus, especially with a status bar.
* NOTRACKBAR Customizable column-width tracking control.
* NODRAGLIST APIs to make a listbox source and sink drag&drop actions.
* NOPROGRESS Progress gas gauge.
* NOHOTKEY HotKey control
*/
/*/////////////////////////////////////////////////////////////////////////*/
/* InitCommonControls:
* Any application requiring the use of any common control should call this
* API upon application startup. There is no required shutdown.
*/
WINCOMMCTRLAPI void WINAPI InitCommonControls();
// Define Ownerdraw type for Header controls BUGBUG: should be in windows.h?
#define ODT_HEADER 100
#define ODT_TAB 101
#define ODT_LISTVIEW 102
//====== Ranges for control message IDs
// (making each control's messages unique makes validation and
// debugging easier).
//
#define LVM_FIRST 0x1000 // ListView messages
#define TV_FIRST 0x1100 // TreeView messages
#define HDM_FIRST 0x1200 // Header messages
#define HANDLE_WM_NOTIFY(hwnd, wParam, lParam, fn) \
(fn)((hwnd), (int)(wParam), (NMHDR FAR*)(lParam))
#define FORWARD_WM_NOTIFY(hwnd, idFrom, pnmhdr, fn) \
(LRESULT)(fn)((hwnd), WM_NOTIFY, (WPARAM)(int)(idFrom), (LPARAM)(NMHDR FAR*)(pnmhdr))
// Generic WM_NOTIFY notification codes
#define NM_OUTOFMEMORY (NM_FIRST-1)
#define NM_CLICK (NM_FIRST-2)
#define NM_DBLCLK (NM_FIRST-3)
#define NM_RETURN (NM_FIRST-4)
#define NM_RCLICK (NM_FIRST-5)
#define NM_RDBLCLK (NM_FIRST-6)
#define NM_SETFOCUS (NM_FIRST-7)
#define NM_KILLFOCUS (NM_FIRST-8)
// WM_NOTIFY codes (NMHDR.code values)
// these are not required to be in seperate ranges but that makes
// validation and debugging easier
#define NM_FIRST (0U- 0U) // generic to all controls
#define NM_LAST (0U- 99U)
#define LVN_FIRST (0U-100U) // listview
#define LVN_LAST (0U-199U)
#define HDN_FIRST (0U-300U) // header
#define HDN_LAST (0U-399U)
#define TVN_FIRST (0U-400U) // treeview
#define TVN_LAST (0U-499U)
#define TTN_FIRST (0U-520U) // tooltips
#define TTN_LAST (0U-549U)
#define TCN_FIRST (0U-550U) // tab control
#define TCN_LAST (0U-580U)
// Shell reserved (0U-580U) - (0U-589U)
#define CDN_FIRST (0U-601U) // common dialog (new)
#define CDN_LAST (0U-699U)
#define TBN_FIRST (0U-700U) // toolbar
#define TBN_LAST (0U-720U)
#define UDN_FIRST (0U-721) // updown
#define UDN_LAST (0U-740) // updown
// Message Filter Proc codes - These are defined above MSGF_USER
#define MSGF_COMMCTRL_BEGINDRAG 0x4200
#define MSGF_COMMCTRL_SIZEHEADER 0x4201
#define MSGF_COMMCTRL_DRAGSELECT 0x4202
#define MSGF_COMMCTRL_TOOLBARCUST 0x4203
//====== IMAGE APIS ==================================================
#define CLR_NONE 0xFFFFFFFFL
#define CLR_DEFAULT 0xFF000000L
struct _IMAGELIST;
typedef struct _IMAGELIST NEAR* HIMAGELIST;
#define ILC_MASK 0x0001 // ImageList has a mask
#define ILC_COLOR 0 // use default
#define ILC_COLORDDB 0x00FE // use device dependent bitmap
#define ILC_COLOR4 0x0004 // use 4bpp DIBSection
#define ILC_COLOR8 0x0008 // use 8bpp DIBSection
#define ILC_COLOR16 0x0010 // use 16bpp DIBSection
#define ILC_COLOR24 0x0018 // use 24bpp DIBSection
#define ILC_COLOR32 0x0020 // use 32bpp DIBSection
WINCOMMCTRLAPI HIMAGELIST WINAPI ImageList_Create(int cx, int cy, UINT flags, int cInitial, int cGrow);
WINCOMMCTRLAPI BOOL WINAPI ImageList_Destroy(HIMAGELIST himl);
WINCOMMCTRLAPI int WINAPI ImageList_GetImageCount(HIMAGELIST himl);
WINCOMMCTRLAPI int WINAPI ImageList_Add(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask);
WINCOMMCTRLAPI int WINAPI ImageList_ReplaceIcon(HIMAGELIST himl, int i, HICON hicon);
WINCOMMCTRLAPI COLORREF WINAPI ImageList_SetBkColor(HIMAGELIST himl, COLORREF clrBk);
WINCOMMCTRLAPI COLORREF WINAPI ImageList_GetBkColor(HIMAGELIST himl);
WINCOMMCTRLAPI BOOL WINAPI ImageList_SetOverlayImage(HIMAGELIST himl, int iImage, int iOverlay);
#define ImageList_AddIcon(himl, hicon) ImageList_ReplaceIcon(himl, -1, hicon)
#define ILD_NORMAL 0x0000 // use current bkcolor
#define ILD_TRANSPARENT 0x0001 // force transparent icon style (override bk color)
#define ILD_MASK 0x0010 // draw the mask
#define ILD_IMAGE 0x0020 // draw the image
#define ILD_BLEND25 0x0002 // blend 25%
#define ILD_BLEND50 0x0004 // blend 50%
#define ILD_OVERLAYMASK 0x0F00 // use these as indexes into special items
#define INDEXTOOVERLAYMASK(i) ((i) << 8) //
#define ILD_SELECTED ILD_BLEND50 // draw as selected
#define ILD_FOCUS ILD_BLEND25 // draw as focused (selection)
#define ILD_BLEND ILD_BLEND50 // blend 50%
#define CLR_HILIGHT CLR_DEFAULT // draw using default color
WINCOMMCTRLAPI BOOL WINAPI ImageList_Draw(HIMAGELIST himl, int i, HDC hdcDst, int x, int y, UINT fStyle);
#ifdef _WIN32
WINCOMMCTRLAPI BOOL WINAPI ImageList_Replace(HIMAGELIST himl, int i, HBITMAP hbmImage, HBITMAP hbmMask);
WINCOMMCTRLAPI int WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hbmImage, COLORREF crMask);
WINCOMMCTRLAPI BOOL WINAPI ImageList_DrawEx(HIMAGELIST himl, int i, HDC hdcDst, int x, int y, int dx, int dy, COLORREF rgbBk, COLORREF rgbFg, UINT fStyle);
WINCOMMCTRLAPI BOOL WINAPI ImageList_Remove(HIMAGELIST himl, int i);
WINCOMMCTRLAPI HICON WINAPI ImageList_GetIcon(HIMAGELIST himl, int i, UINT flags);
WINCOMMCTRLAPI HIMAGELIST WINAPI ImageList_LoadImage(HINSTANCE hi, LPCSTR lpbmp, int cx, int cGrow, COLORREF crMask, UINT uType, UINT uFlags);
WINCOMMCTRLAPI BOOL WINAPI ImageList_BeginDrag(HIMAGELIST himlTrack, int iTrack, int dxHotspot, int dyHotspot);
WINCOMMCTRLAPI void WINAPI ImageList_EndDrag();
WINCOMMCTRLAPI BOOL WINAPI ImageList_DragEnter(HWND hwndLock, int x, int y);
WINCOMMCTRLAPI BOOL WINAPI ImageList_DragLeave(HWND hwndLock);
WINCOMMCTRLAPI BOOL WINAPI ImageList_DragMove(int x, int y);
WINCOMMCTRLAPI BOOL WINAPI ImageList_SetDragCursorImage(HIMAGELIST himlDrag, int iDrag, int dxHotspot, int dyHotspot);
WINCOMMCTRLAPI BOOL WINAPI ImageList_DragShowNolock(BOOL fShow);
WINCOMMCTRLAPI HIMAGELIST WINAPI ImageList_GetDragImage(POINT FAR* ppt,POINT FAR* pptHotspot);
#define ImageList_RemoveAll(himl) ImageList_Remove(himl, -1)
#define ImageList_ExtractIcon(hi, himl, i) ImageList_GetIcon(himl, i, 0)
#define ImageList_LoadBitmap(hi, lpbmp, cx, cGrow, crMask) ImageList_LoadImage(hi, lpbmp, cx, cGrow, crMask, IMAGE_BITMAP, 0)
#ifdef __IStream_INTERFACE_DEFINED__
WINCOMMCTRLAPI HIMAGELIST WINAPI ImageList_Read(LPSTREAM pstm);
WINCOMMCTRLAPI BOOL WINAPI ImageList_Write(HIMAGELIST himl, LPSTREAM pstm);
#endif
typedef struct _IMAGEINFO
{
HBITMAP hbmImage;
HBITMAP hbmMask;
int Unused1;
int Unused2;
RECT rcImage;
} IMAGEINFO;
WINCOMMCTRLAPI BOOL WINAPI ImageList_GetIconSize(HIMAGELIST himl, int FAR *cx, int FAR *cy);
WINCOMMCTRLAPI BOOL WINAPI ImageList_SetIconSize(HIMAGELIST himl, int cx, int cy);
WINCOMMCTRLAPI BOOL WINAPI ImageList_GetImageInfo(HIMAGELIST himl, int i, IMAGEINFO FAR* pImageInfo);
WINCOMMCTRLAPI HIMAGELIST WINAPI ImageList_Merge(HIMAGELIST himl1, int i1, HIMAGELIST himl2, int i2, int dx, int dy);
#endif // _WIN32
//================ HEADER APIS =============================================
//
// Class name: SysHeader (WC_HEADER)
//
// The SysHeader control provides for column and row headers much like those
// found in MSMail and Excel. Header items appear as text on a gray
// background. Items can behave as pushbuttons, in which case they have a
// raised face.
//
// SysHeaders support changing width or height of items using the mouse.
// These controls do not support a keyboard interface, so they do not accept
// the input focus.
//
// There are notifications that allow applications to determine when an item
// has been clicked or double clicked, width change has occured, drag tracking
// is occuring, etc.
//
//////////////////////////////////////////////////////////////////////////////
#ifdef _WIN32
#define WC_HEADER "SysHeader32"
#else
#define WC_HEADER "SysHeader"
#endif
// Header control styles
#define HDS_HORZ 0x00000000 // Horizontal header
#define HDS_BUTTONS 0x00000002 // Items act as buttons
#define HDS_HIDDEN 0x00000008 // don't show the headers (use as info storage), actually goes to 0 height
// The HD_ITEM structure describes a header item.
// The first field contains a combination of HDI_* flags
// indicating which fields contain valid data.
//
typedef struct _HD_ITEM
{
UINT mask;
int cxy; // width (HDS_HORZ) or height (HDS_VERT)
LPSTR pszText;
HBITMAP hbm; // Bitmap to use (implies HDF_BITMAP)
int cchTextMax; // Valid only for GetItem: contains size of buffer
int fmt; // HDF_* value
LPARAM lParam;
} HD_ITEM;
// HD_ITEM mask flags
#define HDI_WIDTH 0x0001
#define HDI_HEIGHT HDI_WIDTH
#define HDI_TEXT 0x0002
#define HDI_FORMAT 0x0004
#define HDI_LPARAM 0x0008
#define HDI_BITMAP 0x0010
// HD_ITEM fmt field values
// First justification values
#define HDF_LEFT 0
#define HDF_RIGHT 1
#define HDF_CENTER 2
#define HDF_JUSTIFYMASK 0x0003
//
// MidEast languages only
#define HDF_RTLREADING 4
// Now other formating options
#define HDF_OWNERDRAW 0x8000
#define HDF_STRING 0x4000
#define HDF_BITMAP 0x2000
// Returns number of items in header.
//
// int Header_GetItemCount(HWND hwndHD);
//
#define HDM_GETITEMCOUNT (HDM_FIRST + 0)
#define Header_GetItemCount(hwndHD) \
(int)SendMessage((hwndHD), HDM_GETITEMCOUNT, 0, 0L)
// Insert header item at specified index. Item is inserted at end if
// i is greater than or equal to the number of items in the header.
// Returns the index of the inserted item.
//
// int Header_InsertItem(HWND hwndHD, int i, const HD_ITEM FAR* pitem);
//
#define HDM_INSERTITEM (HDM_FIRST + 1)
#define Header_InsertItem(hwndHD, i, phdi) \
(int)SendMessage((hwndHD), HDM_INSERTITEM, (WPARAM)(int)(i), (LPARAM)(const HD_ITEM FAR*)(phdi))
// Delete a header item at the specified index.
//
// BOOL Header_DeleteItem(HWND hwndHD, int i);
//
#define HDM_DELETEITEM (HDM_FIRST + 2)
#define Header_DeleteItem(hwndHD, i) \
(BOOL)SendMessage((hwndHD), HDM_DELETEITEM, (WPARAM)(int)(i), 0L)
// Get header item at index i. The mask field of the pointed-to
// HD_ITEM structure indicates which fields will be set by this
// function; other fields are not changed.
//
// The cchTextMax field of *pitem contains the maximum
// length of the returned string.
//
// BOOL Header_GetItem(HWND hwndHD, int i, HD_ITEM FAR* phdi);
//
#define HDM_GETITEM (HDM_FIRST + 3)
#define Header_GetItem(hwndHD, i, phdi) \
(BOOL)SendMessage((hwndHD), HDM_GETITEM, (WPARAM)(int)(i), (LPARAM)(HD_ITEM FAR*)(phdi))
// Set header item at index i. The mask field of the pointed-to
// HD_ITEM structure indicates which header item attributes will
// be changed by this call; other fields of *pitem that do not
// correspond to pitem->mask are ignored.
//
// The cchTextMax of *pitem is ignored.
//
// BOOL Header_SetItem(HWND hwndHD, int i, const HD_ITEM FAR* phdi);
//
#define HDM_SETITEM (HDM_FIRST + 4)
#define Header_SetItem(hwndHD, i, phdi) \
(BOOL)SendMessage((hwndHD), HDM_SETITEM, (WPARAM)(int)(i), (LPARAM)(const HD_ITEM FAR*)(phdi))
// Calculate size and position of header within a rectangle.
// Results are returned in a WINDOWPOS structure you supply,
// and the layout rectangle is adjusted to exclude the leftover area.
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -