?
Solved

Forms in Forms?

Posted on 2003-02-23
9
Medium Priority
?
214 Views
Last Modified: 2013-11-20
How do I put a form into a form? I have a set of controls that I will need to use many times in my program. Is there anyway I can put them all onto a form and then somehow put that form onto another form. I seem to remember being able to do this in VB6 - Can I do it in C++ MFC .Net?
Thank you for your time,
Arrummzen
0
Comment
Question by:Arrummzen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 8006451
put a frame control or a rectangle in your form base.
rename the id of the frame control from IDC_STATIC to IDC_ST1

On your main forms InitialUpdate/OnInitDialog use

CRect rc;
GetDlgItem(IDC_ST1)->GetWindowRect(&rc);
ScreenToClient(&rc);

// create your child dialg by
m_oChildForm.Create(IDD_CHILDDLG, this);

m_oChildForm.MoveWindow(&rc);


This is only a skelton structure, may have some bugs....


Good Luck
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 8006578
Any class derived from CFrameWnd can be parent of the child forms, like CMDIFrameWnd. Child forms may be derived from CFrameWnd or non-modal dialogs.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 8006910
Actually, you are talking about dialog form and not frame. You need to create Composite ActiveX control.
0
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
LVL 1

Author Comment

by:Arrummzen
ID: 8012971
I want to make a stand alone .exe, will an activeX control require extra files or can it be part of the .exe?
Thank you for your time,
Arrummzen
0
 
LVL 9

Expert Comment

by:Priyesh
ID: 8013542
you could do it in MFC too. CFormView derived classes work similar to VB forms.

here is a link to a previously asked question which does something similar to this. It is about creating  a formview in a dialogbar, but the same applies for creating a formview in a dialog or in another formview.

http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_20515498.html
0
 
LVL 1

Author Comment

by:Arrummzen
ID: 8013557
roshmon: So you think I can make another Dialog and then copy it into the First so that I will have one inside another?
Thank you for your time,
Arrummzen
0
 
LVL 1

Author Comment

by:Arrummzen
ID: 8013611
I am getting m_oChildForm - undeclared Identifyer. I know why this is happening but I have no idea how to fix it.

I suppose that I have to make the child form a member varable of the parrent (both Dialog Boxes).
I created a class derived from CDialog to be the child but how to I make this a member of the other Dialog?

Thank you for your time,
Arrummzen
0
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 800 total points
ID: 8297092
Hi Arrummzen,

//////////////////////////
CRect rc;
GetDlgItem(IDC_ST1)->GetWindowRect(&rc);
ScreenToClient(&rc);

// create your child dialg by
m_oChildForm.Create(IDD_CHILDDLG, this);

m_oChildForm.MoveWindow(&rc);

///////////////////////////////////

Let CControlsDlg be the dialog class that contains the controls

Let CMainDlg1, CMainDlg2 are the classes where you what to put these controls.

In both these main dialogs you need to put a static frame named IDC_ST1 (intiallly a static frame have the name of IDC_STATIC, so you have to rename the id to IDC_ST1)

put a member named m_oChildForm in your classe's header files (i.e in your MainDlg1.h, MainDlg2.h)

for that you have to include the class CControlsDlg  in that header files for avoiding object not found/undeclared identifier

#include "ControlsDlg.h"

in tour maindlg class'es header file put
CControlsDlg m_oChildForm;

the code I have wriiten before you can apply on OnInitDialog/OnSize of dialog


Good Luck
0
 
LVL 1

Author Comment

by:Arrummzen
ID: 8317300
Thank you!
Thank you for your time,
Arrummzen
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question