Number of CMDIChildWnd(s) in CMDIFrameWnd

Hi Gurus,
How can I know how many CMDIChildWnds does a CMDIFrameWnd have?
[82 byte] By [Shandrio] at [2007-11-19 18:28:24]
# 1 Re: Number of CMDIChildWnd(s) in CMDIFrameWnd
Is the child frame of single type ( i.e. only one class for childframe windows ? ) ?
kirants at 2007-11-10 23:46:41 >
# 2 Re: Number of CMDIChildWnd(s) in CMDIFrameWnd
Is the child frame of single type ( i.e. only one class for childframe windows ? ) ?

I din't actualy get it... My application is a typical "AppWizzard-made" MDI multiple document app. Hope that answers your question!
Shandrio at 2007-11-10 23:47:46 >
# 3 Re: Number of CMDIChildWnd(s) in CMDIFrameWnd
CMDIFrameWnd has this member:
public:
HWND m_hWndMDIClient; // MDI Client window handle
You could enumerate its child windows, which are your CMDIChildWnds
VladimirF at 2007-11-10 23:48:45 >
# 4 Re: Number of CMDIChildWnd(s) in CMDIFrameWnd
Frankly, I don't understand the question: is it how many child windows are opened in your MDI app, or of how many CMDIChildWnds-derived classes their frames are instances of?
cilu at 2007-11-10 23:49:50 >
# 5 Re: Number of CMDIChildWnd(s) in CMDIFrameWnd
You could use VladimirF's approach using EnumChildWindows API , in which case beware of this: If a child window has created child windows of its own, EnumChildWindows enumerates those windows as well.
You could use VladimirF's approach using GetWindow with GW_CHILD and GW_NEXT/PREV
You could maintain a static int member for the CMDIChildWnd derived class in your project to represent the count of MDICHildWnds. And increment it in the class' constructor and decrement it in the class' destructor, in which case, beware that this will work only if your app uses one childframe class alone.
kirants at 2007-11-10 23:50:46 >
# 6 Re: Number of CMDIChildWnd(s) in CMDIFrameWnd
You could maintain a static int member for the CMDIChildWnd derived class in your project to represent the count of MDICHildWnds. And increment it in the class' constructor and decrement it in the class' destructor, in which case, beware that this will work only if your app uses one childframe class alone.

Thanx a lot kirants, that's simple and works perfectly... exactly the type of solution I was looking for! ;)
Shandrio at 2007-11-10 23:51:50 >