Solved

creating a window with CWnd::CreateEx() problem

Posted on 2002-03-25
6
2,611 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 2

Expert Comment

by:Lockias
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 100
sameEnds challenge 3 105
fizzArray2 challenge 1 56
tripleUp challenge 7 65
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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. …
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

16 Experts available now in Live!

Get 1:1 Help Now