child windows

This is a discussion on child windows within the Windows Programming forums, part of the Platform Specific Boards category; how can i create a child window in Win32 API? is it possible with CreateWindowEx() ?...

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    98

    child windows

    how can i create a child window in Win32 API?
    is it possible with CreateWindowEx() ?

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Please take the time to read through the material referenced when you first asked this question.

    There's also a thread, a couple of posts down from this, Learning Windows Programming, that contains information that is both relevant and helpful to your enquiry.

    Searching this board will bring up plenty of information to help you get started.

    But the short answer is, yes, you can.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Create the window with the WS_CHILD style and set the hWndParent, to the child window's Parent.

  4. #4
    Registered User
    Join Date
    Apr 2005
    Posts
    98
    yea it works now, thanks for the help =)

  5. #5
    Registered User
    Join Date
    Apr 2005
    Posts
    98
    I have another problem:
    i want to pass the handle of the main window to a function, but not a copy of the handle - the handle itself.
    Code:
    void foo(HWND hwnd)
    {
         DisableWindow(hwnd, FALSE);
    }
    
    
    HWND hwndMain;
    foo(hwndMain);
    but the disable just won't work. i tried to get a reference to the handle:
    Code:
    void foo(HWND& hwnd);
    but it doesn't work either.

    what's the solution?

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Quote Originally Posted by hiya
    Code:
    void foo(HWND hwnd)
    {
         DisableWindow(hwnd, FALSE);
    }
    
    
    HWND hwndMain;
    foo(hwndMain);
    This code dose what you would expect, the function DisableWindow is called on the window handle passed to the function named foo. I'm not aware of a windows function named DisableWindow did you mean to use EnableWindow?

  7. #7
    Registered User
    Join Date
    Apr 2005
    Posts
    98
    oops yea, i meant enable.
    well, the function really work but it's not exactly how i do it, thought it will work the same.
    anyway, here's my code more or less:
    Code:
    class Wnd
    {
         protected:
              HWND hwnd;
              HWND hwndParent;
         public:
              Wnd(HWND hParent):hwndParent(hParent) {}
              void foo()
              {
                   EnableWindow(hwndParent, FALSE);
              }
    }
    
    Wnd obj(hwndMain);
    obj.foo();
    and this isn't working... why?

  8. #8
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Probably because hwndMain/hwndParent isn't a valid window handle - what does IsWindow have to say about it?
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  9. #9
    Registered User
    Join Date
    Apr 2005
    Posts
    98
    hwndMain is a valid window handle and hwndParent\hParent isn't.
    why is that? it works in any function but in a class...

  10. #10
    Registered User
    Join Date
    Apr 2005
    Posts
    98
    found my problem: i created that object before i created a window for the hwndMain
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can't create child windows
    By OnionKnight in forum Windows Programming
    Replies: 4
    Last Post: 04-10-2011, 05:13 PM
  2. Displaying Text on MDI child windows
    By EmbeddedC in forum Windows Programming
    Replies: 4
    Last Post: 10-30-2008, 01:28 PM
  3. Keeping child windows in their place
    By Smallz in forum Windows Programming
    Replies: 1
    Last Post: 08-27-2006, 07:22 AM
  4. Child Windows and Messages
    By Terrell in forum Windows Programming
    Replies: 10
    Last Post: 09-05-2002, 07:39 AM
  5. child windows
    By face_master in forum Windows Programming
    Replies: 14
    Last Post: 03-01-2002, 07:08 AM

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