Use subclassdialog (subclass)

Source: Internet
Author: User

A control on subclass dialog!
After a subclass control, replace its original windowproc with the windowproc of cyourcwndclass you wrote yourself, so that you can
You can process all the messages of this control. You can use classwizard to maintain your cyourcwndclass.

In MFC, in addition to subclassdlgitem, The subclasswindow function is used to execute the same function. In association with a widget ID
Then, all messages of the control will have this class to respond. The procedure is as follows:
1. derive a class from the control of subclass, for example, from cedit-> cmyedit;
2. Complete the messages to be processed in cmyedit, such as onchar;
3. Define the member variable m_myedit of a cmyedit class in the dialog box class;
4. Add m_myedit (idc_edit, this) to oninitdialog of dialog );
In this way, when onchar occurs on idc_edit, onchar in cmyedit is called.

In addition, the behavior of replacing another process with a window process is subclassing, which is a derived subclass in the sense of windows.
The derived subclass of the image language is completely different. Subclassdlgitem allows the specified sub-user in the dialog box to control its own window process to replace the default window
Process to intercept messages.

Note: In VC, functions such as ddx_control in the dodataexchange function call subclassdlgitem to subclass the window,
In this way, the control can process messages by itself.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.