Code: Select all
case WM_NOTIFY:
{
if ( !(pgui = GuiType::FindGui(hWnd)) )
break; // Let DefDlgProc() handle it.
NMHDR &nmhdr = *(LPNMHDR)lParam;
if (!nmhdr.idFrom)
{
// This might be the header of a ListView control. Although there may be some
// risk of notification codes being ambiguous for custom controls (between the
// actual control and any child controls), the ability to monitor a ListView's
// header notifications seems useful enough to justify the risk.
control_index = pgui->FindControlIndex(nmhdr.hwndFrom);
}
else
{
control_index = (GuiIndexType)GUI_ID_TO_INDEX(nmhdr.idFrom); // Convert from ID to array index. Relies on unsigned to flag as out-of-bounds.
}
When I suggested OnCtrlNotification() I assumed it would be implemented as an addition to the existing message monitor. I still prefer solution not depending on a GuiControl. GuiControl.OnCommand() and GuiControl.OnNotify() could be preserved as 'syntax sugar', though.