Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MFC Dialog in DLL

Posted on 1998-12-18
6
Medium Priority
?
533 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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. …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

610 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