Solved

MFC Dialog in DLL

Posted on 1998-12-18
6
500 Views
Last Modified: 2013-11-20
I have a DLL which is an extension to Lotus Notes and uses the Notes API. From this DLL i try to pop up a dialog when a certain callback from Notes arrives.
I have made an MFC Extension DLL with the appwizard in VC5(sp3) and created a dialog which I call SetPwdDialog.
When I create an instance of the dialog and do DoModal() I get an assertion error that the resource can not be found.  I understand that this is because NT looks for the resource in the app (Notes) instead of my DLL so i made the code:

int
dialogGetPwd(char *buf, int len)
{
    HINSTANCE mod = LoadLibrary("ssonotes.dll");
    if (mod == NULL)
        return 1;

    AfxSetResourceHandle(mod);
    SetPwdDialog pwd;
    pwd.DoModal();
    return 0;
}

Now it passas the resource assertion but instead traps on the assertion:
_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetInstanceHandle()
      { ASSERT(afxCurrentInstanceHandle != NULL);
            return afxCurrentInstanceHandle; }

What do I need to do to pop up my dialog from within the DLL??
My function dialogGetPwd is called from a function which is exported form the DLL.

Regards,
Tomas
0
Comment
Question by:dd2
[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
6 Comments
 
LVL 8

Expert Comment

by:Answers2000
ID: 1326382
Can you give the line of the assertion please
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1326383
The problem is that you are using an MFC extension DLL. MFC extension DLLs are designed to be used by MFC applications. More than likely, it seems Notes is not an MFC application.

So to get around this problem, create a Regular DLL with MFC either static or dynamically linked in when you're using the wizard.

0
 

Expert Comment

by:george_777
ID: 1326384
Try to use

      AFX_MANAGE_STATE(AfxGetStaticModuleState());

This will help.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:george_777
ID: 1326385
AFX_MANAGE_STATE(AfxGetStaticModuleState());

You have to use above line if your function exported from DLL
uses MFC. This line have to be first line of your function.

(I ma sorry for bad english.)


0
 

Expert Comment

by:george_777
ID: 1326386
AFX_MANAGE_STATE(AfxGetStaticModuleState());

You have to use above line if your function exported from DLL
uses MFC. This line have to be first line of your function.

(I ma sorry for bad english.)


0
 

Author Comment

by:dd2
ID: 1326387
Thanks for the help. When creating a regular dll with MFC dynamically linked, everything works fine. The AFX_MANAGE_STATE is probably needed but the origninal problem was that I had made an MFC extension DLL instead of a normal one.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

734 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