Solved

creating a window with CWnd::CreateEx() problem

Posted on 2002-03-25
6
2,655 Views
Last Modified: 2013-11-20
I derived a class called CAnimWnd from CWnd, registered the window with the call to AfxRegisterWndClass() and then tried to call CreateEx():

BOOL CAnimWnd::Create(const char* pszTitle,DWORD          dwStyle,  CWnd* pParent, int x, int y, int cx, int cy)
{
    const char* pszClassName
        = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW);

    return CWnd::CreateEx(0, pszClassName, pszTitle,  dwStyle, x, y, cx, cy, NULL, NULL);
}

somehow the CWnd::CreateEx() returns false, and the window is not created. For what reasons does the CreateEx() func. returns false?

Any comment is appreciated, working answer receives an A.
0
Comment
Question by:kushcu
6 Comments
 
LVL 3

Expert Comment

by:GGRUNDY
ID: 6895306
In Debug mode set a break point (F9) on your call and step into the MFC source (F11) to get a better idea of what is going wrong. If you look your Debug output Trace window should also report the message
Warning: Window creation failed: GetLastError returns ???
Where ??? is a hex number you can lookup using the "Error lookup" utility.
0
 
LVL 3

Expert Comment

by:job_s
ID: 6895690
or simply U post the creation code we'l find out the problem.
0
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 100 total points
ID: 6895842
I think u need to create a Pop up window right ?
Thats y u used CreateEx in Create Function...
So u need to change the window style to popup
Just like below


return CreateEx(WS_EX_TOOLWINDOW,
                         AfxRegisterWndClass(CS_DBLCLKS),
                         NULL,
                         WS_POPUPWINDOW|WS_BORDER|WS_OVERLAPPED,
                         x, y, cx, cy,
                         pParent,
                         NULL);

GOOD LUCK
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:Lockias
ID: 6897834
I notice you pass the CWnd* pParent to your derived class Create function, but you do not pass this on to the CreateEx function.  Are you settings the WS_CHILD style while setting the parent to NULL?

~Lockias
0
 

Author Comment

by:kushcu
ID: 6904010
i'm kind of in my midterm period right now, i'll check your comments out when i have the time, thanks.
0
 

Author Comment

by:kushcu
ID: 7057555
I tried a diiferent approach to this question that works fine, and feel the need to transfer the points to someone..
Thanks for all your time.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now