Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to close all child windows in MDI?

how to close all child windows in MDI?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zeus_master
    wrote on last edited by
    #1

    how to close all child windows in MDI? like the VC->windows->Close All command

    W R 3 Replies Last reply
    0
    • Z zeus_master

      how to close all child windows in MDI? like the VC->windows->Close All command

      W Offline
      W Offline
      William Wang
      wrote on last edited by
      #2

      EnumChildWindows maybe helpful. life is like a box of chocolate,you never know what you r going to get.

      1 Reply Last reply
      0
      • Z zeus_master

        how to close all child windows in MDI? like the VC->windows->Close All command

        R Offline
        R Offline
        Ram Murali
        wrote on last edited by
        #3

        CMDIChildWnd *pMDIActive; while( pMDIActive = MDIGetActive() ) { pMDIActive->SendMessage(WM_CLOSE); } Regards, Ram

        1 Reply Last reply
        0
        • Z zeus_master

          how to close all child windows in MDI? like the VC->windows->Close All command

          W Offline
          W Offline
          William Wang
          wrote on last edited by
          #4

          yes,I did it with following code: BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam) { ::SendMessage(hwndChild,WM_CLOSE,0,0); return TRUE; } void CMainFrame::OnWindowCloseall() { // TODO: 在此添加命令处理程序代码 ::EnumChildWindows(m_hWndMDIClient,EnumChildProc,0); } life is like a box of chocolate,you never know what you r going to get.

          Z 1 Reply Last reply
          0
          • W William Wang

            yes,I did it with following code: BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam) { ::SendMessage(hwndChild,WM_CLOSE,0,0); return TRUE; } void CMainFrame::OnWindowCloseall() { // TODO: 在此添加命令处理程序代码 ::EnumChildWindows(m_hWndMDIClient,EnumChildProc,0); } life is like a box of chocolate,you never know what you r going to get.

            Z Offline
            Z Offline
            zeus_master
            wrote on last edited by
            #5

            thank you for your reply. I found anoter function: CDocTemplate* pTemplate = pDocument->GetDocTemplate(); pTemplate->CloseAllDocuments(true); though I don't know the progress of the function.

            D 1 Reply Last reply
            0
            • Z zeus_master

              thank you for your reply. I found anoter function: CDocTemplate* pTemplate = pDocument->GetDocTemplate(); pTemplate->CloseAllDocuments(true); though I don't know the progress of the function.

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              zeus_master wrote:

              pTemplate->CloseAllDocuments(true);

              I'm glad you found this. I can't believe that EnumChildWindows() and SendMessage() were suggested.


              "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

              "Judge not by the eye but by the heart." - Native American Proverb

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups