Advertisement

04.08.2008 at 04:12PM PDT, ID: 23306608
[x]
Attachment Details

Creating CWnd child windows and handling their events

Asked by paul129 in Windows MFC Programming, Windows Programming, Microsoft Visual C++

Tags: MFC CWnd

Hi experts,

I am a little confused.. I am trying to include into a mfc dialog-based project a child window created with CWnd class, but I can't get this code working:

CProp::CProp(CWnd* pParent) //Note pParent is the CWnd pointer to my parent window
{
//int x = CWnd::CreateEx(NULL, AfxRegisterWndClass(NULL), NULL, WS_CHILD|WS_VISIBLE|WS_DLGFRAME,0, 0, 120, 120, pParent, (HMENU)NULL);

UINT nID = 1234;
CWnd* pWnd = new CWnd;
LPCTSTR ClassName = (LPCTSTR)AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW,NULL,(HBRUSH)COLOR_BACKGROUND + 1,NULL);


pWnd->CreateEx(0, ClassName, "Win", WS_CHILD | WS_CAPTION|WS_VISIBLE|WS_DLGFRAME,
0, 0, 580, 100, pParent->m_hWnd, (HMENU)NULL);

pWnd->ShowWindow(SW_SHOWNORMAL);
pWnd->CenterWindow();
}


I am always getting Warning: Window creation failed: GetLastError returns 0x0000057E that Lookup says: "Cannot create a top-level child window."

How to solve the problem?

And once created, some link or whatever to understand how window messages (paint, lmouseclick,etc..) may be handled? DoDataExchange system is still available in CWnd windows?

I have a big mess in my mind, any help about this "bad-documented" topic is greatly appreciatedStart Free Trial
 
Loading Advertisement...
 
[+][-]04.08.2008 at 11:53PM PDT, ID: 21312366

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Windows MFC Programming, Windows Programming, Microsoft Visual C++
Tags: MFC CWnd
Sign Up Now!
Solution Provided By: Gurudenis
Participating Experts: 2
Solution Grade: B
 
 
[+][-]04.09.2008 at 12:50AM PDT, ID: 21312645

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628