Click to See Complete Forum and Search --> : MDI document


Jose Romero
April 28th, 1999, 10:34 PM
Two questions for the price of one:
First, how do I prevent the framework from appending a number to each child that is created?.
Second, How do I force a limited number of child windows to be created (i.e one or two only).

Any help would be greatly appreciated.

Thanks,

Jose.

Roger Osborn
April 29th, 1999, 02:32 AM
You can stop the title being fiddled with by overriding the frame's PreCreateWindow and changing the style:

cs.style&=~(LONG)FWS_ADDTOTITLE;

But you might then have to set the title you want with SetWindowText(). It might have turned off all of the title, not just the number. Have a look at CMDIChildWnd::OnUpdateFrameTitle in the MFC source code to see the normal behaviour (assuming it's an MDI app).

For the second question I'm not so sure, but the document template knows how many of its documents exist, so you could derive from the doctemplate(s) and keep track of the count. That assumes you have one view per document. If you can't get at the count in the doctemplate directly then you can count manually using GetFirstDocPosition/GetNextDocPosition. Maybe there's a better way. I've not tried to do this.

Perhaps you could keep a global counter in the app and change it each time a window is created or destroyed? Or use FindFirstWindow/FindNextWindow to iterate over the windows at a given level to give you a count?


Hope that helps a bit,
Cheers,
Roger

Xiaojian Liu
May 14th, 1999, 12:09 PM
Have had this solved out? If not, please drop
me a mail.