Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CWnd.CreateEx

Posted on 2000-02-23
5
Medium Priority
?
263 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 200 total points
ID: 2556842
hmm...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

604 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