I am creating a child window which is derived from a CWnd. If I create the child window using Create, then the window gets created and eveything is fine. But if I create the child window using CreateEx, then I get 2 strange results.
1) If I create the window with a NULL ID, then the windows works fine, except that it has a NULL parent when I call GetParent().
2) If I create the window with any other ID number, then the window doesn't show at all!
I am creating the child window in a Veiw window. Please address the 2 points I pointed out.

Thank you.
Who is Participating?
WynConnect With a Mentor Commented:
Are you sure the place you pass the ID to is the ID parameter? Probably you are confused it with the hwndParent parameter.
Why don't you post the code?
Zainal062797Author Commented:
Sure... Here is the code.

In my view class, I have:

void CTheView::OnEditPoints ()
      m_pwndPointsTables = new CPointsTables;      
      m_pwndPointsTables->CreateTheWindow (this);

In my CPointsTables class, I have:

BOOL CPointsTables::CreateTheWindow (CTheView *pwndParent)
      // register the window class
    CString strWndClass = AfxRegisterWndClass (
        CS_DBLCLKS,                     // Class style
            NULL,                                          // Class cursor
        (HBRUSH) (COLOR_3DFACE + 1),    // Class background brush
        NULL                                          // Class icon

      // calculate the client coordinate
      CRect rect (0, 0, 900, 250);
      pwndParent->GetParent()->ClientToScreen (&rect);

      // create the window and display it according to above window class and coordinate
     return (CreateEx (WS_EX_TOOLWINDOW | WS_EX_OVERLAPPEDWINDOW, strWndClass, "Define Points",
                              rect, pwndParent, NULL));      

I am making the window creation in a separate function to make things neat.
However, if I create the window in the parent window, things work fine. It is only when I do it the way shown above that I get the problem described earlier.
For creating a child window using CreatEx()...
1:You havent specify WS_CHILD style
2:The rect should be parent client coordinates.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.