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
Solved

CWnd.CreateEx

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
Duplicates in Aggregate Query 3 44
Changing the installation path of this MSI 5 106
windbg taking it's time 32 93
Trouble with References... 5 59
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

766 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