Article ID: 261289 - View products that this article applies to.
This article was previously published under Q261289
On a TreeView control with the TVS_CHECKBOXES style, there is no notification that the checked state of the item has been changed. There is also no notification that indicates that the state of the item has changed. However, you can determine that the user has clicked the state icon of the item and act upon that.
When the user clicks the check box of a TreeView item, an NM_CLICK notification is sent to the parent window. When this occurs, the TVM_HITTEST message returns TVHT_ONITEMSTATEICON. The TreeView control uses this same condition to toggle the state of the check box. Unfortunately, the TreeView control toggles the state after the NM_CLICK notification is sent.
You can post a user-defined message to the same window that is processing the NM_CLICK notification, and treat this user-defined message as a notification that the checked state has changed. Following is sample code that illustrates how this can be accomplished: