Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using DLLs made with MFC in a non-MFC app

Posted on 1998-07-02
5
Medium Priority
?
328 Views
Last Modified: 2013-11-25
We would like to be able to use MFC (VC++ 5.0) to make dlls that contain multiple Active X and standard controls and some associated dialogs. We would then need to be able to link to these dll's from other non-MFC programs
that were created by an outside company.
These other programs have well documented pre-defined interfaces that they provide to allow the use of external dll's.
We would need to make the layer that both provides the required environment  for  the Active X controls and  maps the requests from the outside program to the appropiate functions of the Active X controls. Our dll can link to the
MFC dll and any other dll it requires.
Our dlls would typically contain a dialog that had Active X controls in it, much like a "FormView" (dialog) application.

Is this possible and practical?

If so, how do you build a simple prototype for this (for example, a simple non-MFC program that uses a dll
that has a dialog containing an Active X control)?

Since our experience with MFC dll's and Active controls is limited to the basic design methods that the AppWizard
supports, we would need a detailed example or detailed instructions on exactly how to do this.

Paul Titchener
0
Comment
Question by:titchener
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1318698
>Is this possible and practical?
Yes, definitely.

Look into the two MFC samples that come with Visual C++.

DLLTRACE: Writes a DLL Statically Linked to the Framework Library
DLLHUSK: Dynamically Links the MFC Library
0
 
LVL 5

Expert Comment

by:yonat
ID: 1318699
You just need to remember to call AFX_MANAGE_STATE(AfxGetStaticModuleState( )) in each of the DLLs entry points. Other than that, just do everything as usual.
0
 

Author Comment

by:titchener
ID: 1318700
I looked at these 2 examples (DLLTRACE and DLLHUSK) but its not clear to me
that they do what we need. The first example, the dll itself seems to be built outside
the MFC IDE environment using a makefile, and it has no Active X controls.

In the second example the DLL seems to have been built using the IDE, but it doesn't have Active X controls, and its called by a program built using MFC.

Anybody interested in putting together the simple example I described above in
the original question (I'm not being lazy, I've tried to do it and can't get it to work)?
0
 
LVL 2

Accepted Solution

by:
lucidity earned 400 total points
ID: 1318701
If you build a DLL in MFC by definition (and theory) you can use that DLL in any windows programming language.

Heres a link to show how to add a dialog to a DLL
http://www.codeguru.com/dll/dialog_in_dll.shtml

If you need something else let me know.
0
 

Author Comment

by:titchener
ID: 1318702
I've been trying to follow the example mentioned above (http://www.codeguru.com/dll/dialog_in_dll.shtml ). I made a MFC dll that
has two simple dialogs, one with an Active X control, one without. I also made an
MFC app that tries to bring up these dialogs by calling the function below that is
in the DLL:

extern __declspec(dllexport) void ShowNonActiveX(void)
{
      //Ensures that we are using our own resources
      AFX_MANAGE_STATE(AfxGetStaticModuleState());
      CNonActiveX dlg;
      dlg.DoModal();
}

I can step into the function, but when it executes the dlg.DoModal, I get a pop-up
dialog box with the messages:

Debug Assertion Failed:

Program: C:\testdll\debug\testdll.exe
File: afxwin1.inl
Line: 22

I get this message in either Release or Debug mode, when I try to bring
up either dialog (with and without Active X).
Any idea what I'm doing wrong here?


0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question