Zhiyi Zhang (@zhiyi) commented about dlls/comctl32/tests/treeview.c:
DestroyWindow(hTree);
- /* check that expansion can be denied by parent */
- hTree = create_treeview_control(0);
- fill_tree(hTree);
- g_reject_tvn_itemexpanding = 1;
- memset(&item, 0, sizeof(item));
- item.mask = TVIF_STATE;
- item.hItem = hRoot;
- *((HTREEITEM *)&rc) = item.hItem;
- /* Simulate the double-click */
I think using the TVM_EXPAND message to expand or collapse the item is more reliable than sending a click. Also, please test that TVN_ITEMEXPANDINGA returning TRUE can also prevent the item from collapsing.