Solved

creating a window with CWnd::CreateEx() problem

Posted on 2002-03-25
6
2,692 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

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…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.

810 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