Link to home
Start Free TrialLog in
Avatar of yeshengl
yeshenglFlag for United States of America

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!
Avatar of Crius
Crius

Well, if you need to controls to do anything other than standard default behaviour (including capturing messages and processing them their own way), you really should derive some child class from the control base class.

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...
ASKER CERTIFIED SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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