yeshengl
asked on
Controls on Dialog
Hi,
I have a question regarding controls on dialog. Controls on dialog can not catch some windows standard messages. I know one solution is to subclass the controls. But if I have many controls on a dialog, this solution will not be good because I need to subclass too many controls. Is there any good solution for this kind of purpuse? Thank you very much for your help!
I have a question regarding controls on dialog. Controls on dialog can not catch some windows standard messages. I know one solution is to subclass the controls. But if I have many controls on a dialog, this solution will not be good because I need to subclass too many controls. Is there any good solution for this kind of purpuse? Thank you very much for your help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
One more thing -
You don't have to explicitly subclass the control (by calling the SubclassDlgItem function).
You can use the same method MFC uses to attach the control to a data member:
A. declare the data memeber in your h file as an object of the derived class (e.g: CMyEdit m_YourMember).
B. In the DoDataExchange function call:
DDX_Control(pDX, ID_YOUR_CONTROL, m_YourMember)
This call will attach the data member to the control and prevent the need for subclassing.
Good luck
You don't have to explicitly subclass the control (by calling the SubclassDlgItem function).
You can use the same method MFC uses to attach the control to a data member:
A. declare the data memeber in your h file as an object of the derived class (e.g: CMyEdit m_YourMember).
B. In the DoDataExchange function call:
DDX_Control(pDX, ID_YOUR_CONTROL, m_YourMember)
This call will attach the data member to the control and prevent the need for subclassing.
Good luck
This is the best way to do it. Replace all dialog controls you need altered with your own implementation, and anything you don't want changed in the control, don't override its function...