Solved

How Can I use MFC static linked DLL with Win32 Application

Posted on 1999-01-19
1
203 Views
Last Modified: 2013-11-20
I maked a win32 program like bellow

STEP 1. I have built MFC DLL in regular dll with  MFC static linked.
STEP 2. I customized Event Loop
        void checkMFCPanding()
        {
             MSG msg;

             if(GetMessage(&msg, (HWND)NULL, 0, 0)){
                  TranslateMessage(&msg);
    DispatchMessage(&msg);
              }
        }

        void EVENT_MainCustomLoop()
        {
S_Running = BOOL_TRUE;
  NDEvent::Update();
  while (S_Running) {
NDEvent::ProcessPending(); /// win32 Event Process
NDEvent::UpdateCursor();
checkMFCPanding();            /// MFC Event Process
Sleep(50);
   }
   NDEvent::Update();
          }


int main(int argc, char** argv)
{
                |
EVENT_MainCustomLoop(); /// Custom Event Loop
exit(0)
}

STEP3.: I use MFC DLL in explicit aproch.
    HINSTANCE hDll;
    void Oi_testWin1::HitPBut_Exit(void)
    {
FreeLibrary(hDll);
S_Running = BOOL_FALSE;
     }

    void Oi_testWin1::HitPBut_Call(void)
    {
typedef void (*MYPROC)();

MYPROC ProcChildShow;
BOOL fRunTimeLinkSuccess=FALSE;

hDll=LoadLibrary("dll4.dll");

ProcChildShow = (MYPROC) GetProcAddress(hDll, "Show_MyDlg");
if(fRunTimeLinkSuccess =(ProcChildShow != NULL)){
(ProcChildShow)();
}
    }

this can display MFC Dialog in DLL, but another ploblum comes.
The application killed when I call FreeLibrary(hDll) routine.

I really don't know what I made a mistake.
I think maybe step of build DLL (build MFC DLL in regular dll with  MFC static linked.).

Anybody know this, please Let me know as soon as possiblly.
please~~~
0
Comment
Question by:jbpark
[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
1 Comment
 
LVL 31

Accepted Solution

by:
Zoppo earned 100 total points
ID: 1327995
I think your problem is your kind of 'syncronisation' with the S_Running:
In Oi_testWin1::HitPBut_Exit you try to unload the lib although the EVENT_MainCustomLoop() is still running.
Even if you set S_Running to FALSE befor freeing the DLL it's not said that EVENT_MainCustomLoop() terminates correctly in time.

You should use some of the Win32 API's syncronisation (see help).

Post if you have additional questions to syncronisation methods.

ZOPPO

0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pressing cancel button with C# UI Automation 3 90
VBA "SendKeys" Syntax for Multiple Keystrokes 7 125
twoTwo  challenge 35 112
Annoying "thing" blocks my view 4 130
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.

740 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