Solved

CWnd.CreateEx

Posted on 2000-02-23
5
250 Views
Last Modified: 2013-12-03
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.
0
Comment
Question by:Zainal062797
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 2553295
Are you sure the place you pass the ID to is the ID parameter? Probably you are confused it with the hwndParent parameter.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2554780
Why don't you post the code?
0
 

Author Comment

by:Zainal062797
ID: 2555838
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",
                              WS_VISIBLE,
                              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.
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2556839
For creating a child window using CreatEx()...
1:You havent specify WS_CHILD style
2:The rect should be parent client coordinates.

Regards
W.Yinan
0
 
LVL 5

Accepted Solution

by:
Wyn earned 50 total points
ID: 2556842
hmm...
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

734 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