From: David Ching on

"Herby" <prmarjoram(a)gmail.com> wrote in message
news:1163689177.343759.116130(a)h54g2000cwb.googlegroups.com...
>
> 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?
>

If you run Tools | Error Lookup and type in 0x57E, it will say, "Cannot
create a top-level child window."

The pParentWnd parameter is NULL, so you are creating a top-level window. I
had thought Create() could only be used for child windows. Try calling
CreateEx() instead.

-- David


From: Dan Bloomquist on


Herby wrote:

> 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

Are you running a debug build? You should have hit this assert:

// can't use for desktop or pop-up windows (use CreateEx instead)
ASSERT(pParentWnd != NULL);

Try:
pDummyWnd->CreateEx( WS_EX_TOOLWINDOW, _T("Static"), NULL, NULL,
rectDefault, NULL, 0, 0 );

Also, you may consider creating the window object on the stack so you
don't have to delete it.

From: Mubashir Khan on
This is the sample code for hidden window .............

CWnd* pWnd = new CWnd;
pWnd->m_hWnd = NULL;
if (!pWnd->CreateEx(0, AfxRegisterWndClass(0),
_T("Hidden Window"),
WS_OVERLAPPED, 0, 0, 0, 0, NULL, NULL))
{
return FALSE;
}

"Herby" <prmarjoram(a)gmail.com> wrote in message
news:1163689177.343759.116130(a)h54g2000cwb.googlegroups.com...
>
> 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.
>


From: Herby on

Thanks guys, managed to find as easier example by looking in the header
file of CFrameWnd:
It has its own special Create method.

CFrameWnd* pDummyWnd = new CFrameWnd;
pDummyWnd->Create( NULL, "DummyWnd");
m_pMainWnd = pDummyWnd;


Iv got another serious problem now which im going to post in another
thread -
It would be great if you could help me there too.

Thanks.

From: Joseph M. Newcomer on
See below...
On 16 Nov 2006 05:56:56 -0800, "Herby" <prmarjoram(a)gmail.com> wrote:

>
>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 ;
****
I see little reasonto use 'new' here.
Declare a class variable
CWnd DummyWnd;
in your class. Then
DummyWnd.Create(...);
m_pMainWnd = &DummyWnd;
Don't use 'new' when you don't need it.
****
>
>
>Will this do? or should i be doing something else?
****
I've not tried this, but it sounds like a good start.
joe
****
>
>Thanks.
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm