Solved

CWnd.CreateEx

Posted on 2000-02-23
5
229 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
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

760 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

17 Experts available now in Live!

Get 1:1 Help Now