Resource switching in DLL bound to cdialog and its dialog box resources in MFC

Source: Internet
Author: User

I have recently learned more about the process of selecting Resources in the dialog box.
In the general style, the MFC dialog box usually has such a line:
Enum {IDD = XXXXX };

In this dialog box, the constructor usually writes

View Source Code

Print help

1 Invoicedialog: invoicedialog (cwnd * pparent/* = NULL */):
2 Cdialog (invoicedialog: IDD, pparent ),
3 M_invoice (null)
4 {
5 // {Afx_data_init (invoicedialog)
6 // Note: The classwizard will add member initialization here
7 //} Afx_dat _ init
8 Theapp. applicationwindow ()-& gt; m_pactivehelphandler =This;
9 }

However, many people may not understand how the project binds a cdialog to a dialog box resource based on this IDD number.
Sometimes there are more than one project and more than one resource. How does ide select the resource location?
Because my recent aplanet project involves multiple languages
Each Language Pack DLL is a bunch of dialog resources and resources are available in the main project.
After painstaking exploration, I found several key global functions of afx:
Afxgetresourcehandle ()
Afxsetresourcehandle ()
AfxGetInstanceHandle ()

Afxgetresourcehandle () and afxsetresourcehandle () constitute a temporary storage system (also can be understood as a stack with a height of only 1). When we specify to use the dialog box Resources of the current project, you can write it like this:

View Source Code

Print help

1 HinstanceH = afxgetresourcehandle ();
2 Afxsetresourcehandle (AfxGetInstanceHandle ());
3 Invoicedialog ST (This);
4 St. domodal ();
5 Afxsetresourcehandle (h );

AfxGetInstanceHandle () ensures that the resource handle in the main project is obtained.
Both afxgetresourcehandle () and afxsetresourcehandle () ensure that this process is not affected.ProgramOther parts obtain the resource location

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.