Key Points of Using DLL to reference cdialog in a dynamic library using MFC

Source: Internet
Author: User

In the Application Development of MFC, some functions are often encapsulated and called in the DLL dynamic library. The following points should be noted during the call process:

1. Set the current resource handle

When searching resource files in DLL, set the handle of the current resource file to the hinstance of the DLL module if necessary.

Afxgetresourcehandle () view the current resource handle

Afxsetresourcehandle () sets the current resource handle

Getmodulehandle ("DLL file name ");

Example:

Hinstance H1 = afxgetresourcehandle ();
Hmodule hmod = getmodulehandlea ("ActiveX. ocx ");
If (hmod = NULL) hmod = getmodulehandlea ("ActiveX. dll ");
Afxsetresourcehandle (hmod );

 

2. COM Initialization and container settings are required when ActiveX is called in DLL.

Oleinitialize (null); COM interface Initialization

Afxenablecontrolcontainer () allows applications to be used as control containers.

 

The problems currently encountered are basically the above two points. New discoveries will be added in the future.

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.