Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

Forms in Forms?

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
Arrummzen
Asked:
Arrummzen
  • 4
  • 2
  • 2
  • +1
1 Solution
 
Roshan DavisCommented:
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
 
AlexFMCommented:
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
 
AlexFMCommented:
Actually, you are talking about dialog form and not frame. You need to create Composite ActiveX control.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
ArrummzenAuthor Commented:
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
 
PriyeshCommented:
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
 
ArrummzenAuthor Commented:
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
 
ArrummzenAuthor Commented:
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
 
Roshan DavisCommented:
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
 
ArrummzenAuthor Commented:
Thank you!
Thank you for your time,
Arrummzen
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now