|
-
Nov 30th, 2001, 09:13 PM
#1
Thread Starter
Addicted Member
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.
-
Dec 2nd, 2001, 10:33 AM
#2
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.
-
Dec 3rd, 2001, 08:24 PM
#3
Thread Starter
Addicted Member
sorry... but i don't quite understand your meaning...
-
Dec 4th, 2001, 09:25 AM
#4
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.
-
Dec 5th, 2001, 02:30 AM
#5
Thread Starter
Addicted Member
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...
-
Dec 5th, 2001, 10:11 AM
#6
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.
-
Dec 9th, 2001, 08:51 PM
#7
Thread Starter
Addicted Member
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.
-
Dec 11th, 2001, 02:26 AM
#8
Thread Starter
Addicted Member
woh... that's a problem... is it really that hard?
-
Dec 11th, 2001, 08:51 AM
#9
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.
-
Dec 12th, 2001, 05:00 AM
#10
Thread Starter
Addicted Member
Attached is the InitInstance function that I've written.
Thanks.
-
Dec 12th, 2001, 11:47 AM
#11
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.
-
Dec 13th, 2001, 08:25 PM
#12
Thread Starter
Addicted Member
So, you reckon that I use different ChildFrame class for each of my FormView, isn't it?
-
Dec 14th, 2001, 07:50 AM
#13
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.
-
Dec 14th, 2001, 10:22 PM
#14
Thread Starter
Addicted Member
OK. Thanks a lot. You've been very helpful.
I know what I should do now.
Thanks again! Have a nice day...
-
Dec 24th, 2004, 07:43 PM
#15
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|