Okay, so I’m implementing grouping in legacy MFC application(that part of code has comments from 2000).
It has custom rendering of items, list itself contains items as it’s id’s and number of columns, without any textcontent.
All items info painted out by some custom behavior is derived from CListCtrl
and it calls ImageList_DrawEx()
, DrawText()
instead of SetItemText()
and for one column it also places a button in an apropriate to rowcolumb rectangle.
So when I added LVGS_COLLAPSIBLE
grouping it somehow worked well with all that rendering, except for buttons, which is not hides when item that contains it is being collapsed with it’s group. Buttons stays where they were and overlaps with other items.
I figured that i can simply hideremove buttons when item draw function occurs on item in collapsed group, but it seems that draw function being called on item only when item is visible and not collapsed.
So I need a way to handle change of group state, but I don’t collapseexpand groups myself.
All groups state is LVGS_COLLAPSIBLE
or (0x08)
so they be collapsedexpanded in GUI by default, so when group is LVGS_COLLAPSED
or (0x01)
– I can check it’s state
// idOfChangedGroup = ???;
LVGROUP group = { 0 };
group.cbSize = sizeof(group);
group.mask = LVGF_STATE;
group.stateMask = LVGS_NORMAL | LVGS_COLLAPSIBLE | LVGS_COLLAPSED;
GetGroupInfo(idOfChangedGroup, &group);
if (group.state & LVGS_COLLAPSED){
// hide button associated with item
}
else{
// show button associated with item
}
But I can’t figure out where to get taht changed group id, I’m not proficient in MFC, but I think it should be done somehow with OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
or OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult)
.
But I cant find any notification messages related to change of group state.
Please give me some advice or direction!
That stuff is so OLD and I’m strugling finding any useful info…