console app + Dialog DLL problems 
Author Message
 console app + Dialog DLL problems

Hail everyone,

I've got problem with interbreeding console app and Dll with Nonmodal Dialog
in it. :)
Dll.h:
class CTestDLLApp : public CWinApp {
    CTestDlg m_xDlg;
public:
    CTestDLLApp();
    virtual BOOL InitInstance();
    DECLARE_MESSAGE_MAP()

Quote:
}

Dll.cpp
BOOL CTestDLLApp::InitInstance() {
    CWinApp::InitInstance();
    m_xDlg.Create(CTestDlg::IDD, NULL);
    m_xDlg.ShowWindow(SW_SHOW);
    return TRUE;
Quote:
}

CTestDlg is empty class with defined OnPaint() and resource IDD
Standard stuff from examples, nothing special.

Console.cpp
HINSTANCE hDllInst = LoadLibrary("TestDLL.dll");
_getch();
FreeLibrary(hDllInst);

That's it.
So, what I like is that after LoadLibrary I can see dialog window.
But what I don't like is that dialog process hangs while console wait for
getch() and can't even repaint itself.

Probably that's predicted behaviour, but I've no idea how to avoid dialog
from{*filter*}.
So, what I'd like to see, that is console application and dll dialog work
independent from each other, but with possibility for console app to call
some exported function from the same dll.

Any help is appreciated.
Thank you in advance.



Sun, 07 Aug 2005 17:58:13 GMT  
 console app + Dialog DLL problems
This is an interesting issue.

I think the cause might be the message queue. Because the console
application has not message queue while the interaction between you and the
dialog generated by DLL is implemented through windows message. Please note
repaint also depends on windows message. As a result, if you load the DLL
from your console application, you will find the dialog hang.

At the same time, if you load the DLL from a window application, for
example a dialog application, you will find the problem goes away.

1, Use MFC template to create a dialog application.
2, add the code into the OnOK function:
void CWinexeDlg::OnOK()
{
        // TODO: Add extra validation here
        hDllInst = LoadLibrary("G:\\my work\\post\\16199943 interaction_console
app+dll dialog\\test\\dll\\Debug\\dll.dll");

Quote:
}

3, add the code into OnCancle function:
void CWinexeDlg::OnCancel()
{
        // TODO: Add extra cleanup here
               FreeLibrary(hDllInst);  
        CDialog::OnCancel();
Quote:
}

--------------------

::Subject: console app + Dialog DLL problems
::Date: Wed, 19 Feb 2003 10:58:13 +0100
::Lines: 42
::X-Priority: 3
::X-MSMail-Priority: Normal
::X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
::X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106

::Newsgroups: microsoft.public.vc.language
::NNTP-Posting-Host: 213.201.179.140
::Path: cpmsftngxa08!cppssbbsa01.microsoft.com!TK2MSFTNGP08!TK2MSFTNGP12
::Xref: cpmsftngxa08 microsoft.public.vc.language:182287
::X-Tomcat-NG: microsoft.public.vc.language
::
::Hail everyone,
::
::I've got problem with interbreeding console app and Dll with Nonmodal
Dialog
::in it. :)
::Dll.h:
::class CTestDLLApp : public CWinApp {
::    CTestDlg m_xDlg;
::public:
::    CTestDLLApp();
::    virtual BOOL InitInstance();
::    DECLARE_MESSAGE_MAP()
::}
::Dll.cpp
::BOOL CTestDLLApp::InitInstance() {
::    CWinApp::InitInstance();
::    m_xDlg.Create(CTestDlg::IDD, NULL);
::    m_xDlg.ShowWindow(SW_SHOW);
::    return TRUE;
::}
::CTestDlg is empty class with defined OnPaint() and resource IDD
::Standard stuff from examples, nothing special.
::
::Console.cpp
::HINSTANCE hDllInst = LoadLibrary("TestDLL.dll");
::_getch();
::FreeLibrary(hDllInst);
::
::That's it.
::So, what I like is that after LoadLibrary I can see dialog window.
::But what I don't like is that dialog process hangs while console wait for
::getch() and can't even repaint itself.
::
::Probably that's predicted behaviour, but I've no idea how to avoid dialog
::from{*filter*}.
::So, what I'd like to see, that is console application and dll dialog work
::independent from each other, but with possibility for console app to call
::some exported function from the same dll.
::
::Any help is appreciated.
::Thank you in advance.
::
::
::

This posting is provided "AS IS" with no warranties, and confers no rights.



Mon, 08 Aug 2005 17:56:09 GMT  
 console app + Dialog DLL problems
Thanks for the answer, Justin. I almost gave up waiting.

Indeed, in windows app it works perfect. And I thought about absence of
message queue in console app, so I made a test. When I open simple
MessageBox after LoadLibrary in the same console app, dialog in dll works,
and after I close message box, it hangs again.

So, somehow message box affects dialog in dll.

Are there any ways to make dialog in dll independent from console app?

Best regards.


Quote:
> This is an interesting issue.

> I think the cause might be the message queue. Because the console
> application has not message queue while the interaction between you and
the
> dialog generated by DLL is implemented through windows message. Please
note
> repaint also depends on windows message. As a result, if you load the DLL
> from your console application, you will find the dialog hang.

> At the same time, if you load the DLL from a window application, for
> example a dialog application, you will find the problem goes away.

> 1, Use MFC template to create a dialog application.
> 2, add the code into the OnOK function:
> void CWinexeDlg::OnOK()
> {
> // TODO: Add extra validation here
> hDllInst = LoadLibrary("G:\\my work\\post\\16199943 interaction_console
> app+dll dialog\\test\\dll\\Debug\\dll.dll");
> }

> 3, add the code into OnCancle function:
> void CWinexeDlg::OnCancel()
> {
> // TODO: Add extra cleanup here
>                FreeLibrary(hDllInst);
> CDialog::OnCancel();
> }
> --------------------

> ::Subject: console app + Dialog DLL problems
> ::Date: Wed, 19 Feb 2003 10:58:13 +0100
> ::Lines: 42
> ::X-Priority: 3
> ::X-MSMail-Priority: Normal
> ::X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
> ::X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106

> ::Newsgroups: microsoft.public.vc.language
> ::NNTP-Posting-Host: 213.201.179.140
> ::Path: cpmsftngxa08!cppssbbsa01.microsoft.com!TK2MSFTNGP08!TK2MSFTNGP12
> ::Xref: cpmsftngxa08 microsoft.public.vc.language:182287
> ::X-Tomcat-NG: microsoft.public.vc.language
> ::
> ::Hail everyone,
> ::
> ::I've got problem with interbreeding console app and Dll with Nonmodal
> Dialog
> ::in it. :)
> ::Dll.h:
> ::class CTestDLLApp : public CWinApp {
> ::    CTestDlg m_xDlg;
> ::public:
> ::    CTestDLLApp();
> ::    virtual BOOL InitInstance();
> ::    DECLARE_MESSAGE_MAP()
> ::}
> ::Dll.cpp
> ::BOOL CTestDLLApp::InitInstance() {
> ::    CWinApp::InitInstance();
> ::    m_xDlg.Create(CTestDlg::IDD, NULL);
> ::    m_xDlg.ShowWindow(SW_SHOW);
> ::    return TRUE;
> ::}
> ::CTestDlg is empty class with defined OnPaint() and resource IDD
> ::Standard stuff from examples, nothing special.
> ::
> ::Console.cpp
> ::HINSTANCE hDllInst = LoadLibrary("TestDLL.dll");
> ::_getch();
> ::FreeLibrary(hDllInst);
> ::
> ::That's it.
> ::So, what I like is that after LoadLibrary I can see dialog window.
> ::But what I don't like is that dialog process hangs while console wait
for
> ::getch() and can't even repaint itself.
> ::
> ::Probably that's predicted behaviour, but I've no idea how to avoid
dialog
> ::from{*filter*}.
> ::So, what I'd like to see, that is console application and dll dialog
work
> ::independent from each other, but with possibility for console app to
call
> ::some exported function from the same dll.
> ::
> ::Any help is appreciated.
> ::Thank you in advance.
> ::
> ::
> ::

> This posting is provided "AS IS" with no warranties, and confers no
rights.



Mon, 08 Aug 2005 19:16:44 GMT  
 console app + Dialog DLL problems
To make dialog in DLL works fine, we must let it has a fine message queue
without any effects from the console application which has no message queue.

The simple method is to let DLL create a process which show a dialog.
Because the thread which masters the dialog in a different process so that
its message queue won't be affected from the original process (console
application + DLL). Please note, DLL runs as a part of the process which
loads it.
--------------------



::Subject: Re: console app + Dialog DLL problems
::Date: Thu, 20 Feb 2003 12:16:44 +0100
::Lines: 119
::X-Priority: 3
::X-MSMail-Priority: Normal
::X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
::X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106

::Newsgroups: microsoft.public.vc.language
::NNTP-Posting-Host: 213.201.179.140
::Path: cpmsftngxa06!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12
::Xref: cpmsftngxa06 microsoft.public.vc.language:183672
::X-Tomcat-NG: microsoft.public.vc.language
::
::Thanks for the answer, Justin. I almost gave up waiting.
::
::Indeed, in windows app it works perfect. And I thought about absence of
::message queue in console app, so I made a test. When I open simple
::MessageBox after LoadLibrary in the same console app, dialog in dll works,
::and after I close message box, it hangs again.
::
::So, somehow message box affects dialog in dll.
::
::Are there any ways to make dialog in dll independent from console app?
::
::
::
::Best regards.
::
::
::

::
::> This is an interesting issue.
::>
::> I think the cause might be the message queue. Because the console
::> application has not message queue while the interaction between you and
::the
::> dialog generated by DLL is implemented through windows message. Please
::note
::> repaint also depends on windows message. As a result, if you load the
DLL
::> from your console application, you will find the dialog hang.
::>
::> At the same time, if you load the DLL from a window application, for
::> example a dialog application, you will find the problem goes away.
::>
::> 1, Use MFC template to create a dialog application.
::> 2, add the code into the OnOK function:
::> void CWinexeDlg::OnOK()
::> {
::> // TODO: Add extra validation here
::> hDllInst = LoadLibrary("G:\\my work\\post\\16199943 interaction_console
::> app+dll dialog\\test\\dll\\Debug\\dll.dll");
::> }
::>
::> 3, add the code into OnCancle function:
::> void CWinexeDlg::OnCancel()
::> {
::> // TODO: Add extra cleanup here
::>                FreeLibrary(hDllInst);
::> CDialog::OnCancel();
::> }
::> --------------------

::> ::Subject: console app + Dialog DLL problems
::> ::Date: Wed, 19 Feb 2003 10:58:13 +0100
::> ::Lines: 42
::> ::X-Priority: 3
::> ::X-MSMail-Priority: Normal
::> ::X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
::> ::X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106

::> ::Newsgroups: microsoft.public.vc.language
::> ::NNTP-Posting-Host: 213.201.179.140
::> ::Path: cpmsftngxa08!cppssbbsa01.microsoft.com!TK2MSFTNGP08!TK2MSFTNGP12
::> ::Xref: cpmsftngxa08 microsoft.public.vc.language:182287
::> ::X-Tomcat-NG: microsoft.public.vc.language
::> ::
::> ::Hail everyone,
::> ::
::> ::I've got problem with interbreeding console app and Dll with Nonmodal
::> Dialog
::> ::in it. :)
::> ::Dll.h:
::> ::class CTestDLLApp : public CWinApp {
::> ::    CTestDlg m_xDlg;
::> ::public:
::> ::    CTestDLLApp();
::> ::    virtual BOOL InitInstance();
::> ::    DECLARE_MESSAGE_MAP()
::> ::}
::> ::Dll.cpp
::> ::BOOL CTestDLLApp::InitInstance() {
::> ::    CWinApp::InitInstance();
::> ::    m_xDlg.Create(CTestDlg::IDD, NULL);
::> ::    m_xDlg.ShowWindow(SW_SHOW);
::> ::    return TRUE;
::> ::}
::> ::CTestDlg is empty class with defined OnPaint() and resource IDD
::> ::Standard stuff from examples, nothing special.
::> ::
::> ::Console.cpp
::> ::HINSTANCE hDllInst = LoadLibrary("TestDLL.dll");
::> ::_getch();
::> ::FreeLibrary(hDllInst);
::> ::
::> ::That's it.
::> ::So, what I like is that after LoadLibrary I can see dialog window.
::> ::But what I don't like is that dialog process hangs while console wait
::for
::> ::getch() and can't even repaint itself.
::> ::
::> ::Probably that's predicted behaviour, but I've no idea how to avoid
::dialog
::> ::from{*filter*}.
::> ::So, what I'd like to see, that is console application and dll dialog
::work
::> ::independent from each other, but with possibility for console app to
::call
::> ::some exported function from the same dll.
::> ::
::> ::Any help is appreciated.
::> ::Thank you in advance.
::> ::
::> ::
::> ::
::>
::> This posting is provided "AS IS" with no warranties, and confers no
::rights.
::>
::
::
::

This posting is provided "AS IS" with no warranties, and confers no rights.



Mon, 08 Aug 2005 20:47:11 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. problem launching dialog from console app

2. dll and console app problem?

3. DLL initialization problem in console app

4. Need help converting a console app to windows app with a DLL

5. Create modeless dialog box in console app

6. Dialogs from console app

7. Dialog box in a Console App

8. Access Violation when creating a dialog in a C++ console app

9. Library-generated dialogs from console app

10. Create modeless dialog box in console app

11. Using the CONSOLE for output from a Dialog-based MFC App

12. Console App using Dialogs Issue

 

 
Powered by phpBB® Forum Software