From: Herby on
I have an MFC application hosting a COM component.
It has not got a user interface and so has no window classes.

I get the following error message when attempting to run it:

Warning: m_pMainWnd is NULL in CWinApp::Run - quitting application.


Is there a way round this or must i have a dummy window?

What is the best and most efficient way to cure this problem?

Thanks.

From: Mubashir Khan on
Override the run method. do not call the base method ... do whatever u
have to do and then return with exitinstance ... something like this

int CMainApp::Run()
{
return ExitInstance();
}
"Herby" <prmarjoram(a)gmail.com> wrote in message
news:1163670767.243341.237750(a)h54g2000cwb.googlegroups.com...
>I have an MFC application hosting a COM component.
> It has not got a user interface and so has no window classes.
>
> I get the following error message when attempting to run it:
>
> Warning: m_pMainWnd is NULL in CWinApp::Run - quitting application.
>
>
> Is there a way round this or must i have a dummy window?
>
> What is the best and most efficient way to cure this problem?
>
> Thanks.
>


From: Joseph M. Newcomer on
That's what I would expect to happen with an app that had no GUI.

Overriding Run() can be fairly complex because you have to handle the COM events yourself,
instead of letting the built-in mechanisms handle them for you.

I'd suggest creating a dummy invisible window as the simplest solution.
joe

On 16 Nov 2006 01:52:47 -0800, "Herby" <prmarjoram(a)gmail.com> wrote:

>I have an MFC application hosting a COM component.
>It has not got a user interface and so has no window classes.
>
>I get the following error message when attempting to run it:
>
>Warning: m_pMainWnd is NULL in CWinApp::Run - quitting application.
>
>
>Is there a way round this or must i have a dummy window?
>
>What is the best and most efficient way to cure this problem?
>
>Thanks.
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Herby on

Joseph M. Newcomer wrote:
> That's what I would expect to happen with an app that had no GUI.
>
> Overriding Run() can be fairly complex because you have to handle the COM events yourself,
> instead of letting the built-in mechanisms handle them for you.
>
> I'd suggest creating a dummy invisible window as the simplest solution.
> joe
>

Im currently experimenting with this idea. As after InitInstance
finishes it must keep running to handle incoming COM events.

Currently im thinking of something like....


CWnd* pDummyWnd = new CWnd;
pDummyWnd->Create();
m_pMainWnd = pDummyWnd ;


Will this do? or should i be doing something else?

Thanks.

From: Herby on

Im having a serious problem trying to create a dummy main window...

CRect rectDefault;
CWnd* pDummyWnd = new CWnd;
pDummyWnd->Create( NULL, "DummyWnd", WS_OVERLAPPEDWINDOW,
rectDefault, NULL, 0L, NULL);

Getting

Warning: Window creation failed: GetLastError returns 0x0000057E

What are the correct parameters for creating the main window?

Please help.

Thanks.