Results 1 to 15 of 15

Thread: Specify the size of Child Frame

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Posts
    130

    Specify the size of Child Frame

    Good day, everybody...

    I'm using an MDI Form. Now, I've created a few Child Frames. The problem is: how can I specify the size of the Child Frames when they show up? In other words, I need to specify different sizes for different Child Frame. How do I do that?

    Thanks.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    MDICREATESTRUCT has the necessary fields
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Posts
    130
    sorry... but i don't quite understand your meaning...

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    are you using MFC?
    Well, then it's not that easy... Let me see... *goes off to search the MSDN archives...
    ...
    ...
    ...
    *hours pass by
    ...
    ...
    ...
    *comes out of archives, dusty all over

    Well, I found the solution
    Your CChildFrame class must have a member function named PreCreateWindow. You have a reference to a CREATESTRUCT passed to it. This is a structure that contains all information about the window being created. Among other members, it contains the x, y, cx and cy members. Those are x-position, y-position, x-size and y-size.
    Code:
    BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
    	// TODO: Modify the Window class or styles here by modifying
    	//  the CREATESTRUCT cs
    
    	cs.x = 23;
    	cs.y = 14;
    	cs.cx = 587;
    	cs.cy = 23;
    	if( !CMDIChildWnd::PreCreateWindow(cs) )
    		return FALSE;
    
    	return TRUE;
    }
    This creates a very long but flat window at the point 23/14 relative to the upper left corner of your frame window.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Posts
    130
    Thanks CornedBee...

    Tried it, it works. But what if I have several Child Frames (forms) and each has to be displayed in difference sizes?

    For your infomation, I'm using a MDIForm.

    Sorry for bothering you...

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Do you have several child frame classes (you have different ways of showing one document type or you have several document types) or several instances of one child frame class (i.e. those frames all contain the same type of document and show it in the same way)?

    case A: every class has it's own PreCreateWindow function

    case B: you need to find out which window it is and take the appropriate action.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Posts
    130
    Yupe, each child frame has its own class.

    I did try to modify the PreCreateWindow function of each child frame classes but nothing seems to happen. In other words, the frames only behave according what is written on PreCreateWindow function of ChildFrm class.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Posts
    130
    woh... that's a problem... is it really that hard?

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Can you prove that you don't use the same child frame class each time? I can't use my compiler, but maybe you can at least show me your document template definitions (in CYourApp::InitInstance)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Posts
    130
    Attached is the InitInstance function that I've written.

    Thanks.

  11. #11
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Exactly what I suspected:
    PHP Code:
    // Register the application's document templates. Document templates 
    // serve as the connection between documents, frame windows and views. 
    m_pMainDocTemplate = new CMultiDocTemplate(
       
    IDR_ACCOUNTTYPE,
       
    RUNTIME_CLASS(CAccountsDoc),
       
    RUNTIME_CLASS(CChildFrame), // custom MDI child frame
       
    RUNTIME_CLASS(CAccountsView));
    AddDocTemplate(m_pMainDocTemplate); //
    // 
    m_pWContractDocTemplate[WndWCAgreement] = new CMultiDocTemplate(
       
    IDR_ACCOUNTTYPE,
       
    RUNTIME_CLASS(CAccountsDoc),
       
    RUNTIME_CLASS(CChildFrame), // custom MDI child frame
       
    RUNTIME_CLASS(CWCAgreement_Form)); 
    AddDocTemplate(m_pWContractDocTemplate[WndWCAgreement]);

    m_pWContractDocTemplate[WndWCProgress] = new CMultiDocTemplate(
       
    IDR_ACCOUNTTYPE,
       
    RUNTIME_CLASS(CAccountsDoc),
       
    RUNTIME_CLASS(CChildFrame), // custom MDI child frame
       
    RUNTIME_CLASS(CWCProgress_Form));
    AddDocTemplate(m_pWContractDocTemplate[WndWCProgress]);

    // And and and... 
    Now that's a ***** load of document templates...

    The problem is that you always use the same child frame class:
    RUNTIME_CLASS(CChildFrame), // custom MDI child frame
    You need to change this if you want each frame to have a different size.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Posts
    130
    So, you reckon that I use different ChildFrame class for each of my FormView, isn't it?

  13. #13
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Yes, or in PreCreateWindow you find out the view class and act accordingly. But I don't know how to find that out.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Posts
    130
    OK. Thanks a lot. You've been very helpful.

    I know what I should do now.

    Thanks again! Have a nice day...

  15. #15
    Addicted Member
    Join Date
    Sep 2004
    Location
    Cleveland
    Posts
    148

    Re: Specify the size of Child Frame

    . . . that answers an old question I had about starting a child frame maximized. . . thanks CornedBee. . . You help a messload of people on this thing, you know that?

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