Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

creating a window with CWnd::CreateEx() problem

Posted on 2002-03-25
6
Medium Priority
?
2,904 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 300 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

972 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