Closing Child Windows

This is a discussion on Closing Child Windows within the Windows Programming forums, part of the Platform Specific Boards category; Can anyone tell me what message I should be sending to the message queue in order to close a child ...

  1. #1
    Funniest man in this seat minesweeper's Avatar
    Join Date
    Mar 2002
    Posts
    801

    Closing Child Windows

    Can anyone tell me what message I should be sending to the message queue in order to close a child window without closing the whole application?

    Currently I am sending the WM_CLOSE message to the child window procedure but the whole application closes. Could I be including the incorrect window handle in the SendMessage command?

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    317
    So, your SendMessage command looks like? If you just post that please give a list of you handles, at least which one is the main and which is the child window.

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Use the DestroyWindow() API function, it sends the required WM_DESTROY and WM_NCDESTROY messages. If the window you are destroying has its own child windows, they are also destroyed.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Funniest man in this seat minesweeper's Avatar
    Join Date
    Mar 2002
    Posts
    801
    Sorry I am at work so don't have my code (I program for a hobby). Will post it once I have it.

  5. #5
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    WM_CLOSE is just a message. if your child window doesn't handle it, it won't do anything. DestroyWindow() needs to be called either where the child handles the WM_CLOSE that you sent or in the parent.

  6. #6
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    oops, looks like I just repeated after adrianxw. Oh well

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Displaying Text on MDI child windows
    By EmbeddedC in forum Windows Programming
    Replies: 4
    Last Post: 10-30-2008, 12:28 PM
  2. Keeping child windows in their place
    By Smallz in forum Windows Programming
    Replies: 1
    Last Post: 08-27-2006, 06:22 AM
  3. Windows Form App as parent, Directx as child??
    By yetti82 in forum C++ Programming
    Replies: 3
    Last Post: 05-29-2006, 03:04 AM
  4. Menu Item Caption - /a for right aligned Accelerator?
    By JasonD in forum Windows Programming
    Replies: 6
    Last Post: 06-25-2003, 11:14 AM
  5. child windows
    By face_master in forum Windows Programming
    Replies: 14
    Last Post: 03-01-2002, 06:08 AM

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