getting all open MDI child windows from CMainFrame 
Author Message
 getting all open MDI child windows from CMainFrame

Hi,
I generated an MDI application using appwizard and then removed all the
document/view stuff and use my own CMDIChildWnd derived classes as the MDI
childs. Now, I would like to get  a list of all MDI childs from the MDI
frame class (CMainFrame). Could someone tell me how this can be achieved?

--tia
Rajesh Vijayakumar



Sun, 25 Jun 2000 03:00:00 GMT  
 getting all open MDI child windows from CMainFrame

Quote:
> Hi,
> I generated an MDI application using appwizard and then removed all the
> document/view stuff and use my own CMDIChildWnd derived classes as the
MDI
> childs. Now, I would like to get  a list of all MDI childs from the MDI
> frame class (CMainFrame). Could someone tell me how this can be achieved?

> --tia
> Rajesh Vijayakumar

CWnd* pWnd=m_wndMDIClient.GetWindow(GW_CHILD);
while( NULL != pWnd )
{
        if(pWnd->IsKindOf(RUNTIME_CLASS(CMDIChildWnd)))
                //LOOK! There is one!
        pWnd->GetWindow(GW_HWNDNEXT);        

Quote:
}      

cU
--

                        http://www.geocities.com/TimesSquare/1658/


Sun, 25 Jun 2000 03:00:00 GMT  
 getting all open MDI child windows from CMainFrame

hi,
thanks for the fast reply, but i have some more questions.
the member 'm_wndMDIClient' doesn't seem to be a member of CMDIFrameWnd or
it's parent CFrameWnd. If it is supposed to be added by me to CMainFrame,
how am i going to initialize it? (ie how to get the MDI client window from
the MDI frame window)

once again, thanks for helping.

--regards
Rajesh Vijayakumar


Quote:
>> Hi,
>> I generated an MDI application using appwizard and then removed all the
>> document/view stuff and use my own CMDIChildWnd derived classes as the
>MDI
>> childs. Now, I would like to get  a list of all MDI childs from the MDI
>> frame class (CMainFrame). Could someone tell me how this can be achieved?

>> --tia
>> Rajesh Vijayakumar

>CWnd* pWnd=m_wndMDIClient.GetWindow(GW_CHILD);
>while( NULL != pWnd )
>{
> if(pWnd->IsKindOf(RUNTIME_CLASS(CMDIChildWnd)))
> //LOOK! There is one!
> pWnd->GetWindow(GW_HWNDNEXT);
>}

>cU
>--

> http://www.geocities.com/TimesSquare/1658/



Sun, 25 Jun 2000 03:00:00 GMT  
 getting all open MDI child windows from CMainFrame

Quote:

> I generated an MDI application using appwizard and then removed all the
> document/view stuff and use my own CMDIChildWnd derived classes as the MDI
> childs. Now, I would like to get  a list of all MDI childs from the MDI
> frame class (CMainFrame). Could someone tell me how this can be achieved?

Try ::EnumChildWindows on the mdi client.  Here's some code:

// example callback procedure for EnumChildWindows
BOOL CALLBACK MyEnumChildProc(HWND hwndChild, LPARAM lParam)
{
        // hwndChild contains the handle of the window that is
    // being enumerated.
    CMyMDIChildWnd* pWnd =
            (CMyMDIChildWnd*)CWnd::FromHandle(hwndChild);

        CString sText;
        pWnd->GetWindowText(sText);
        // do stuff with the text
    return TRUE;

Quote:
}

// example call to enum
// this one enums the MDI Child frames in your app
        ::EnumChildWindows(((CMDIFrameWnd*)AfxGetMainWnd()->m_hWndMDIClient,
                              MyEnumChildProc, 0L);

NOTE: The MDI client member in CMDIFrameWnd is named m_hWndMDIClient, not
m_wndMDIClient.

Jim [VC/MFC MVP]
To send mail, change nospam to msn



Mon, 26 Jun 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. getting all open MDI child windows from CMainFrame

2. Opening a new MDI child when no MDI Child exists

3. Opening a new MDI child from a MDI Child

4. Start an MDI App without an open Child Window

5. Get count and list of opened child windows(documents) in MDI application

6. Finding if an MDI child window is open

7. MDI Child window fails to open - why?

8. MDI open new child windows

9. MDI child window flikers when open to maximize state

10. How can I calculate amout open the same child windows in MDI application

11. MDI child window not getting maximised?

12. How to open MDI child window when file selected

 

 
Powered by phpBB® Forum Software