Solved

creating a window with CWnd::CreateEx() problem

Posted on 2002-03-25
6
2,717 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 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