CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Jul 2007
    Posts
    52

    Question [Solved]Adding a CWnd child window

    Hi all

    I am a newbie with CWnd classes and I would like to know how I can implement a little child window inside another one using the CWnd class (I don't want the resource template)

    I created a normal mfc dialog based project and added a CWnd class to my project, then added a member variable to the main dialog class and initialized the CWnd's constructor with a pointer to main dialog (parent) 'this'

    The constructor of the CWnd class is:

    CProp::CProp(CWnd* pParent)
    {
    //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."


    If you'd be so kind to solve this problem and maybe linking me a guide or something to learn (after shown the child window) how to use pDX data exchanges and handlers with a CWnd window like above, I will be extremely grateful

    Any help appreciated, thanks again
    Last edited by NasterMain; April 9th, 2008 at 05:51 AM. Reason: Problem Solved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured