간단한 MDI애플리케이션을 만들어보고 있습니다.
MainMenu가 있는 창에 2개의 MDIChild폼을 생성하는건데 말이죠,
Inspector에서 MainMenu창의 FormStyle을 fsNormal로 했을때는 제대로 컴파일은
되지만, 의도한바가 아니듯이, MainMenu Form내에 ChildForm이 생성되지 아니하고,
외부에 창이 생성됩니다. 총 3개의 FormStyle을 fsMDIChild로 지정해주고 컴파일을
시도하면, 다음과 같은 에러메세지를 내면서, CPU창이 뜹니다.
4번이나 재차 프로젝트를 시도해봤지만, 절대루 안되네요. @,@;;;;...!
파일도 첨부했습니다. 도움이 될려나 모르겠지만.. 이렇게 무식하게 올려봅니다.
┌──────────────────┐ MDIChild_2 : Unit1.cpp
│File Window │ MDIChild_3 : Unit3.cpp
├┬─────────────────┤ MainMenu : Unit3.cpp
││ ┌───────┐ │
│├─MDIChild_1 │ MDIChild_1 ├┐│ ----------------------
││ └─┬─────┘││ 파일첨부
││ │ MDIChild_2 ││ ----------------------
│└─MDIChild_2 └──────┘│ Borland C++ Builder 3
├─────┐ ( O ) │
│Minimized │ FormStyle=fsMDIChild │
└─────┴────────────┘
┌────────────────────────────────────┐
│Error [x] │
├────────────────────────────────────┤
│[X] Project Project1.exe raised exception class EinvalidOperation with │
│ message 'Cannot create form. No MDI forms are currently active'. │
│ Process stopped. Use Step or Run to continue. │
│ ┌───────┐ │
│ │ OK │ │
│ └───────┘ │
└────────────────────────────────────┘
//-------------------------------------------------------------------------
//unit1.h
//-------------------------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Menus.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TMainMenu *MainMenu1;
TMenuItem *File1;
TMenuItem *FirstChild1;
TMenuItem *SecondChild1;
TMenuItem *N1;
TMenuItem *Exit1;
TMenuItem *Window1;
TMenuItem *Tile1;
TMenuItem *Cascade1;
TMenuItem *ArrangeIcons1;
TMenuItem *N2;
TMenuItem *ActiveChild1;
TMemo *Memo1;
void __fastcall FirstChild1Click(TObject *Sender);
void __fastcall SecondChild1Click(TObject *Sender);
void __fastcall Tile1Click(TObject *Sender);
void __fastcall Cascade1Click(TObject *Sender);
void __fastcall ArrangeIcons1Click(TObject *Sender);
void __fastcall ActiveChild1Click(TObject *Sender);
void __fastcall Exit1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
//unit.cpp
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
#include "Unit3.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FirstChild1Click(TObject *Sender)
{
Application->CreateForm(__classid(TForm2), &Form2);
Form2->WindowState=wsNormal;
Form2->Show();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SecondChild1Click(TObject *Sender)
{
Application->CreateForm(__classid(TForm2), &Form2);
Form2->WindowState=wsNormal;
Form2->Show();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Tile1Click(TObject *Sender)
{
Tile();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Cascade1Click(TObject *Sender)
{
Cascade();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ArrangeIcons1Click(TObject *Sender)
{
int i;
for(i=MDIChildCount-1; i>=0; i--)
MDIChildren[i]->WindowState=wsMinimized;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ActiveChild1Click(TObject *Sender)
{
ShowMessage(ActiveMDIChild->Caption);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Exit1Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
//Unit2.h
//---------------------------------------------------------------------------
#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm2 : public TForm
{
__published: // IDE-managed Components
TLabel *FirstChildForm;
private: // User declarations
public: // User declarations
__fastcall TForm2(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm2 *Form2;
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
//Unit2.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
//Unit3.h
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef Unit3H
#define Unit3H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm3 : public TForm
{
__published: // IDE-managed Components
TLabel *SecondChildForm;
private: // User declarations
public: // User declarations
__fastcall TForm3(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm3 *Form3;
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
//Unit3.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit3.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm3 *Form3;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
여기까지 보신분 계시나여? ^^; 흘~ --; 이 수밖에 엄네요~ -.-!
|