Skip to content

Instantly share code, notes, and snippets.

@kjk
Created December 31, 2019 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjk/7c2a26c1be0cd6b992ddd45d7902a456 to your computer and use it in GitHub Desktop.
Save kjk/7c2a26c1be0cd6b992ddd45d7902a456 to your computer and use it in GitHub Desktop.
Sumatra checkbox in tree view (made with https://codeeval.dev)
https://docs.microsoft.com/en-us/windows/win32/controls/tree-view-control-reference
https://docs.microsoft.com/en-us/windows/win32/controls/tree-view-controls#tree-view-image-lists
https://docs.microsoft.com/en-us/windows/win32/controls/tree-view-controls#tree-view-styles
https://docs.microsoft.com/en-us/windows/win32/controls/tree-view-control-window-styles
typedef struct tagTVITEMCHANGE {
NMHDR hdr;
UINT uChanged;
HTREEITEM hItem;
UINT uStateNew;
UINT uStateOld;
LPARAM lParam;
} NMTVITEMCHANGE;
typedef struct _nmhdr {
HWND hwndFrom;
UINT idFrom;
UINT code;
} NMHDR;
typedef struct tagNMTREEVIEWA {
NMHDR hdr;
UINT action;
TVITEMA itemOld;
TVITEMA itemNew;
POINT ptDrag;
} NMTREEVIEWA, *LPNMTREEVIEWA;
https://docs.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-tvitemw
typedef struct tagTVITEMA {
UINT mask;
HTREEITEM hItem;
UINT state;
UINT stateMask;
LPSTR pszText;
int cchTextMax;
int iImage;
int iSelectedImage;
int cChildren;
LPARAM lParam;
} TVITEMA, *LPTVITEMA;
TVS_CHECKBOXES
State image 1 is the unchecked box and state image 2 is the checked box. Setting the state image to zero removes the check box altogether.
https://docs.microsoft.com/en-us/windows/win32/api/Commctrl/ns-commctrl-tvitemexa
Vista+
typedef struct tagTVITEMEXA {
UINT mask;
HTREEITEM hItem;
UINT state;
UINT stateMask;
LPSTR pszText;
int cchTextMax;
int iImage;
int iSelectedImage;
int cChildren;
LPARAM lParam;
int iIntegral;
UINT uStateEx;
HWND hwnd;
int iExpandedImage;
int iReserved;
} TVITEMEXA, *LPTVITEMEXA;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment