アプリケーションの作成

プロジェクトファイル(ProjectManyForm.lzh)

1.「ファイル->新規作成->アプリケーション」

Unit1:メインのウインドウ(Form1)の作成 Unit1.cppUnit1.h

2.「ファイル->新規作成->ユニット」

Unit2:計算用の関数の作成 Unit2.cppUnit2.h

3.「ファイル->新規作成->フォーム」

Unit3:追加フォーム(ファイルの閲覧および編集;Form2)の作成 Unit3.cppUnit3.h

4.「ファイル->フォーム->バージョン情報」

Unit4:バージョン情報(AboutBox1)の作成 Unit4.cppUnit4.h

5.Unit1.cppを表示してから、「ファイル->ユニットヘッダーファイルの追加」を用いてUnit2.hUnit3.hUnit4.hを追加する。

6.書き加えるファイルを示す。

Unit2.hファイル

//---------------------------------------------------------------------------

#ifndef Unit2H

#define Unit2H

//  挿入開始

#include <stdio.h>

#include <fstream.h>      // fout fin

#include <math.h>         // exp() log() sqrt()

#include <vector>

using namespace std;

class Analysis

{

public:

        Analysis();

        ~Analysis();

};                       // ;を必ずつけること

//---------------------------------------------------------------------------

extern PACKAGE Analysis C;

// この行を書くこと

// #include <Unit2.h>を挿入した.cppファイルでは、 C.関数名 Analysisの関数が呼び出せる。

//---------------------------------------------------------------------------

#endif

Unit2.cpp

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "Unit2.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

// 挿入開始

const double   q=1.60210E-19;    // C

const double   epsi0=8.854E-12;  // F/m

const double   m0=9.1091E-31;    // Kg

const double   h=6.6256E-34;     // J*s

const double   k=1.38054E-23;    // J*K^-1

const double   pi=3.1415927;     //

Analysis::Analysis()

{

}

Analysis::~Analysis()

{

}

7.自動的に作成されたUnit1ファイルを示す。

Unit1.hファイル

//---------------------------------------------------------------------------

#ifndef Unit1H

#define Unit1H

//---------------------------------------------------------------------------

#include <Classes.hpp>

#include <Controls.hpp>

#include <StdCtrls.hpp>

#include <Forms.hpp>

//---------------------------------------------------------------------------

class TForm1 : public TForm

{

__published:     // IDE 管理のコンポーネント

private:        // ユーザー宣言

public:                // ユーザー宣言

        __fastcall TForm1(TComponent* Owner);

};

//---------------------------------------------------------------------------

extern PACKAGE TForm1 *Form1;

//---------------------------------------------------------------------------

#endif

Unit1.cppファイル

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "Unit1.h"

#include "Unit2.h"

#include "Unit3.h"

#include "Unit4.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(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 管理のコンポーネント

private:        // ユーザー宣言

public:                // ユーザー宣言

        __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)

{

}

//---------------------------------------------------------------------------

Unit4.hファイル

#ifndef Unit4H

#define Unit4H

//----------------------------------------------------------------------------

#include <vcl\System.hpp>

#include <vcl\Windows.hpp>

#include <vcl\SysUtils.hpp>

#include <vcl\Classes.hpp>

#include <vcl\Graphics.hpp>

#include <vcl\Forms.hpp>

#include <vcl\Controls.hpp>

#include <vcl\StdCtrls.hpp>

#include <vcl\Buttons.hpp>

#include <vcl\ExtCtrls.hpp>

//----------------------------------------------------------------------------

class TAboutBox : public TForm

{

__published:

        TPanel *Panel1;

        TImage *ProgramIcon;

        TLabel *ProductName;

        TLabel *Version;

        TLabel *Copyright;

        TLabel *Comments;

        TButton *OKButton;

private:

public:

        virtual __fastcall TAboutBox(TComponent* AOwner);

};

//----------------------------------------------------------------------------

extern PACKAGE TAboutBox *AboutBox;

//----------------------------------------------------------------------------

#endif   

Unit4.cppファイル

//---------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "Unit4.h"

//---------------------------------------------------------------------

#pragma resource "*.dfm"

TAboutBox *AboutBox;

//---------------------------------------------------------------------

__fastcall TAboutBox::TAboutBox(TComponent* AOwner)

        : TForm(AOwner)

{

}

//---------------------------------------------------------------------