Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
264 views
in Technique[技术] by (71.8m points)

What should I do to use MFC dialogs from other libraries in my C++ project?

I have an MFC ActiveX control project written in Visual Studio 2008 that contains a dialog box. The dialog box is wrapped in a class, as is normal. I want to use the dialog box in another project. Since an ActiveX (.ocx) file is a DLL, I can merely use the ActiveX file as I would a DLL.

The problem I ran into is that the dialog box's class has this near the top:

// Dialog Data
    //{{AFX_DATA(CDeploymentDlg)
    enum { IDD = IDD_DEPLOYMENT };

IDD_DEPLOYMENT is defined in the OCX's resource.h file. My current project also has a resource.h file. When I build my current project, I get an error because IDD_DEPLOYMENT is missing in my current project's resource.h file. My workaround was to copy the OCX project's resource.h file into a file named DeploymentDlgResource.h in my current project, and #include it before I #include the declaration for the dialog class.

This should work for now because I won't need any more dialog boxes in my current project. But what would happen if I created a project that needed another dialog box? What if that second dialog box also came from a separate library? Do I always need to use duplicate resource files like this? Do I have to worry about possible duplication of numbers used in them?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...