done some further digging and found the reason - one of the most bizarre features of Windows' controls.
In "Listview Bugs and Problems" http://www.wdj.com/notgone/706art.htm Ron Burke explains:
Sure enough, the listview control located this flaw in my code for me, due to an "interesting" part of its design. When I started to edit an item in the listview control, as soon as I pressed a key my dialog disappeared! This was indeed mysterious, and I did a lot of head scratching before I finally realized that somebody was generating a notification for either my IDOK button or my IDCANCEL button. Further inspection revealed that the notification code was either 0x0300 or 0x0400. That's when the awful truth hit me.
When you edit a listview item, the listview control secretly creates its own edit control, positioned above the item being edited. Apparently, the listview control designer decided it would be nice to pass that edit control's notification messages on to the parent dialog. All well and good, but what control ID should be associated with those notifications? In a better world, the designer might have allocated a new reserved control ID (e.g., ID_LISTVIEWEDIT), adding to the existing reserved IDs such as IDOK and IDCANCEL. Instead, the designer decided just to use IDOK for the control ID of the edit control. After all, the edit control notifications, such as EN_CHANGE (0x0300) and EN_UPDATE (0x0400), happen to lie numerically above any possible button notifications.
Like so many aspects of the Windows API, this feature of the listview control is not documented. That could indicate Microsoft does not want to guarantee support for the feature in future versions, or it could just be a symptom of the generally incomplete documentation. Either way, be aware that notifications from unrelated controls may be stacked upon your IDOK button -- notifications aren't really guaranteed by the documentation to be there in future versions of the listview control.
When you edit a listview item, the listview control secretly creates its own edit control, positioned above the item being edited. Apparently, the listview control designer decided it would be nice to pass that edit control's notification messages on to the parent dialog. All well and good, but what control ID should be associated with those notifications? In a better world, the designer might have allocated a new reserved control ID (e.g., ID_LISTVIEWEDIT), adding to the existing reserved IDs such as IDOK and IDCANCEL. Instead, the designer decided just to use IDOK for the control ID of the edit control. After all, the edit control notifications, such as EN_CHANGE (0x0300) and EN_UPDATE (0x0400), happen to lie numerically above any possible button notifications.
Like so many aspects of the Windows API, this feature of the listview control is not documented. That could indicate Microsoft does not want to guarantee support for the feature in future versions, or it could just be a symptom of the generally incomplete documentation. Either way, be aware that notifications from unrelated controls may be stacked upon your IDOK button -- notifications aren't really guaranteed by the documentation to be there in future versions of the listview control.
I hope this will help somebody else struggling with in-place editing.
Regards
Lasse Rantanen
[email protected]
Leave a comment: