Смекни!
smekni.com

Основы разработки электронного учебника (стр. 4 из 4)

TShiftState Shift, int X, int Y)

{

fl=true;

}

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

void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift,

int X, int Y)

{

fl=false;

}

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

void __fastcall TForm1::SpeedButton2MouseMove(TObject *Sender,

TShiftState Shift, int X, int Y)

{

Form1->Repaint();

}

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

// Файл Unit2.cpp для главной формы Form2

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

#include <vcl.h>

#pragma hdrstop

#include "Unit2.h"

#include "Unit1.h"

#include "Unit3.h"

#include "Unit4.h"

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

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm2 *Form2;

int i=0;

bool fg1,fg2;

int v1,v2,c2;

int SelPos;

AnsiString a;

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

__fastcall TForm2::TForm2(TComponent* Owner)

: TForm(Owner)

{

}

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

void __fastcall TForm2::SpeedButton1Click(TObject *Sender)

{

Application->Terminate();

}

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

void __fastcall TForm2::TreeView1DblClick(TObject *Sender)

{

if (Form2->TreeView1->Selected->AbsoluteIndex==1)

{Form2->Memo1->Lines->LoadFromFile("pages/1.dat");

a=Form2->Memo1->Lines->Text;

};

if (Form2->TreeView1->Selected->AbsoluteIndex==2)

{Form2->Memo1->Lines->LoadFromFile("pages/2.dat");

a=Form2->Memo1->Lines->Text;

};

if (Form2->TreeView1->Selected->AbsoluteIndex==3)

{Form2->Memo1->Lines->LoadFromFile("pages/3.dat");

a=Form2->Memo1->Lines->Text;

};

if (Form2->TreeView1->Selected->AbsoluteIndex==4)

{Form2->Memo1->Lines->LoadFromFile("pages/4.dat");

a=Form2->Memo1->Lines->Text;

};

if (Form2->TreeView1->Selected->AbsoluteIndex==5)

{Form2->Memo1->Lines->LoadFromFile("pages/5.dat");

a=Form2->Memo1->Lines->Text;

};

if (Form2->TreeView1->Selected->AbsoluteIndex==6)

{Form2->Memo1->Lines->LoadFromFile("pages/6.dat");

a=Form2->Memo1->Lines->Text;

};

if (Form2->TreeView1->Selected->AbsoluteIndex==7)

{Form2->Memo1->Lines->LoadFromFile("pages/7.dat");

a=Form2->Memo1->Lines->Text;

};

if (Form2->TreeView1->Selected->AbsoluteIndex==8)

{Form2->Memo1->Lines->LoadFromFile("pages/8.dat");

a=Form2->Memo1->Lines->Text;

};

if (Form2->TreeView1->Selected->AbsoluteIndex==9)

{Form2->Memo1->Lines->LoadFromFile("pages/9.dat");

a=Form2->Memo1->Lines->Text;

};

if (Form2->TreeView1->Selected->AbsoluteIndex==10)

{Form2->Memo1->Lines->LoadFromFile("pages/10.dat");

a=Form2->Memo1->Lines->Text;

};

…………………………………………………………

}

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

void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action)

{

Application->Terminate();

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

void __fastcall TForm2::N6Click(TObject *Sender)

{ if (FontDialog1->Execute())

{Form2->Memo1->Font=Form2->FontDialog1->Font;

Form2->TreeView1->Font=Form2->FontDialog1->Font;

}

}

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

void __fastcall TForm2::SpeedButton3Click(TObject *Sender)

{

int z=Form2->TreeView1->Items->Owner->Selected->SelectedIndex;

if (z<Form2->TreeView1->Items->Count-1){

Form2->TreeView1->Items->Item[z+1]->Selected=true;

Form2->TreeView1->OnDblClick(Sender); }

}

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

void __fastcall TForm2::SpeedButton2Click(TObject *Sender)

{

int z=Form2->TreeView1->Items->Owner->Selected->SelectedIndex;

if (z>0){

Form2->TreeView1->Items->Item[z-1]->Selected=true;

Form2->TreeView1->OnDblClick(Sender);}

}

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

void __fastcall TForm2::TreeView1KeyDown(TObject *Sender, WORD &Key,

TShiftState Shift)

{

if (Key==VK_RETURN){Form2->SpeedButton3->OnClick(Sender);}

}

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

void __fastcall TForm2::Memo1KeyDown(TObject *Sender, WORD &Key,

TShiftState Shift)

{

if (Key==VK_RETURN){Form2->SpeedButton3->OnClick(Sender);}

}

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

void __fastcall TForm2::N4Click(TObject *Sender)

{

Form3->Visible=true;

}

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

void __fastcall TForm2::N3Click(TObject *Sender)

{

Form4->Visible=true;

}

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

void __fastcall TForm2::N7Click(TObject *Sender)

{

Form2->FindDialog1->Execute();

}

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

void __fastcall TForm2::FindDialog1Find(TObject *Sender)

{AnsiString d;

for (i=0;i<Form2->FindDialog1->FindTextA.Length();i++)

{d=d+i;}

if (Form2->FindDialog1->Options.Contains(frFindNext)) {

SelPos=a.Pos(Form2->FindDialog1->FindTextA);

if (SelPos>0){

Memo1->SelStart=SelPos-1;

Memo1->SelLength=Form2->FindDialog1->FindTextA.Length();

a.Delete(SelPos,Form2->FindDialog1->FindTextA.Length());

a.Insert(d,SelPos);

}

else {

ShowMessage("Текст '"+Form2->FindDialog1->FindTextA+"' не найден");

a=Form2->Memo1->Lines->Text;}

Form2->SetFocus();

Form2->Memo1->SetFocus();}

}

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

void __fastcall TForm2::N9Click(TObject *Sender)

{

if (Form2->N9->Checked) {

Form2->N9->Checked=false;

Form2->SpeedButton1->ShowHint=false;

Form2->SpeedButton2->ShowHint=false;

Form2->SpeedButton3->ShowHint=false;

Form2->TreeView1->ShowHint=false;

}

else {Form2->N9->Checked=true;

Form2->SpeedButton1->ShowHint=true;

Form2->SpeedButton2->ShowHint=true;

Form2->SpeedButton3->ShowHint=true;

Form2->TreeView1->ShowHint=true;

}

}

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

void __fastcall TForm2::SpeedButton4Click(TObject *Sender)

{

if (SaveDialog1->Execute()) {

Memo1->Lines->SaveToFile(SaveDialog1->FileName);

}

ChDir(ExtractFilePath(Application->ExeName));

}

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

// Файл Unit3.cpp для формы Form3

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

#include <vcl.h>

#pragma hdrstop

#include "Unit3.h"

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

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm3 *Form3;

int c3;

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

__fastcall TForm3::TForm3(TComponent* Owner)

: TForm(Owner)

{

}

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

void __fastcall TForm3::SpeedButton1Click(TObject *Sender)

{

Form3->Close();

}

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

Файл Unit4.cpp для формы Form4

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

#include <vcl.h>

#pragma hdrstop

#include "Unit4.h"

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

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm4 *Form4;

int c4;

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

__fastcall TForm4::TForm4(TComponent* Owner)

: TForm(Owner)

{

}

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

void __fastcall TForm4::SpeedButton1Click(TObject *Sender)

{

Form4->Close();

}

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


Приложение Б

Диаграмма вариантов использования