?
Solved

MFC Dialog in DLL

Posted on 1998-12-18
6
Medium Priority
?
511 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 400 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
Technology Partners: 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month8 days, 19 hours left to enroll

764 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