How to collect Active X controls in the MFC dialog
I know we can enumerate the windows controls with in the dialog and using the callback we can collect the windows controls.
I am looking for specific way to filte开发者_运维技巧ring out the controls based on interface implementation. For example, If the Active-X controls derives from interface IDataControl, I want that to add to my interest collection list.
Here is the generic process to get the ole/active-x controls inside the dialog.
- Do EnumWindows with the callback
- In the callback, attach the windows handle to CWnd
Try to get IUnknown pointer for the control CWnd::GetControlUnknown
Tips: How to detect whether a control is standard or active-x control?If returned IUnknown is not null, do queryInterface for IDataControl.
- If IDataControl instance not null, add to collection
精彩评论