Removing/Hiding Child Windows

This is a discussion on Removing/Hiding Child Windows within the Windows Programming forums, part of the Platform Specific Boards category; I don't have much experience in Win32 coding. I have created a window and placed some child windows (buttons) on ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    4

    Removing/Hiding Child Windows

    I don't have much experience in Win32 coding. I have created a window and placed some child windows (buttons) on my window. I want it so that when I click a button those child windows (i.e. the buttons) disappear and new options come up for what to do (meaning I have an "accounts" button and when you click it the accounts page should replace what is currently there). I have the msg loop set up fine so that when I click the accounts button the new child windows for the account pages do come up, but the old child windows that were on the original page are still there (e.g. the accounts button that I just clicked). How do I get rid of those original child windows?

    I tried: RedrawWindow(m_hWnd, NULL, NULL, RDW_ERASENOW | RDW_ALLCHILDREN)
    but that didnít do anything (m_hWnd is the handle to my main window). Is there a function I need to call to delete/hide all the child windows as I move from section to section, or if not, what else should I be doing to have it work as I want?

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    You can delete a window using the DestroyWindow function or you can hide/show it using ShowWindow with either SW_HIDE or SW_SHOW respectively.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    4
    Hmm, how will I know which ones are on the page? Is there a function that destroys all child windows for a given parent?

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    EnumChildWindows enumerates the child windows and permits you to take any action on each in turn so, you might call ShowWindow or DestroyWindow as suggested by anonytmouse previously within the corresponding EnumChildProc.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Another option is to create 'page' windows which you use as the parent for related controls. You can then hide/show the appropriate page. You could also use child dialogs.

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. Child windows
    By beene in forum Windows Programming
    Replies: 2
    Last Post: 12-13-2006, 04:22 AM
  4. Keeping child windows in their place
    By Smallz in forum Windows Programming
    Replies: 1
    Last Post: 08-27-2006, 07:22 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