Cannot create MDI Client Win

This is a discussion on Cannot create MDI Client Win within the Windows Programming forums, part of the Platform Specific Boards category; I'm trying to make an MDI application, but my code to create the client window keeps failing. GetLastError() returns 1406 ...

  1. #1
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972

    Cannot create MDI Client Win

    I'm trying to make an MDI application, but my code to create the client window keeps failing. GetLastError() returns 1406 (Cannot create a top level child window). As far as I can tell, I'm doing exactly what The Forger does to create the client window (and the only difference between that and MSDN is using CreateWindowEx instead of CreateWindow):
    Code:
     CLIENTCREATESTRUCT ccs; 
     
      // Retrieve the handle to the window menu and assign the 
      // first child window identifier. 
      ccs.hWindowMenu = GetSubMenu(GetMenu(m_hwnd), IDX_MDIMENU); 
      ccs.idFirstChild = 0; 
     
      // Create the MDI client window. 
     
      m_hwndMDIClient = CreateWindowEx(WS_EX_CLIENTEDGE, "mdiclient", NULL,
            WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
            m_hwnd, (HMENU)IDC_MAIN_MDI, GetModuleHandle(NULL), (LPVOID)&ccs);
    
      if(!m_hwndMDIClient)
      {
        char temp[50];
        MessageBox(NULL,"Could not create MDI Client window!",itoa(GetLastError(),temp,10),MB_OK);
        return NULL;
      }
    I'm obviously doing something wrong, but I have no idea how I should change it
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Wow took me a while but I figured out the problem. I was setting m_hwnd (a class member variable) to the return value of CreateWindow for my frame window. Of course, since this code was executing inside the WM_CREATE command for the frame window, CreateWindow hadn't returned yet and m_hwnd was invalid.
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting text into MDI program
    By Rutabega in forum Windows Programming
    Replies: 0
    Last Post: 12-23-2005, 11:25 AM
  2. Replies: 1
    Last Post: 09-18-2005, 10:06 PM
  3. TCP/IP client & echo server
    By Jordban in forum C++ Programming
    Replies: 2
    Last Post: 06-06-2005, 07:39 PM
  4. help with this
    By tyrantil in forum C Programming
    Replies: 18
    Last Post: 01-30-2005, 04:53 PM
  5. Can I get this to loop back?
    By Unregistered in forum C Programming
    Replies: 9
    Last Post: 05-07-2002, 04:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21