Thread: Removing/Hiding Child Windows

  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, 04:13 PM
  2. Displaying Text on MDI child windows
    By EmbeddedC in forum Windows Programming
    Replies: 4
    Last Post: 10-30-2008, 12: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, 06:22 AM
  5. child windows
    By face_master in forum Windows Programming
    Replies: 14
    Last Post: 03-01-2002, 07:08 AM