CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: MDI document

  1. #1
    Join Date
    May 1999
    Location
    Ontario, Canada
    Posts
    6

    MDI document

    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.



  2. #2
    Join Date
    Apr 1999
    Posts
    48

    Re: MDI document

    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







  3. #3
    Join Date
    May 1999
    Posts
    22

    Re: MDI document

    Have had this solved out? If not, please drop
    me a mail.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured