p align="left">{ try { Application->Initialize(); Application->CreateForm(__classid(TForm1), &Form1); Application->CreateForm(__classid(TForm3), &Form3); Application->CreateForm(__classid(TForm4), &Form4); { Rgn=CreateEllipticRgn(0,0,Form1->Width,Form1->Height); SetWindowRgn(Form1->Handle,Rgn,True); } Application->CreateForm(__classid(TForm2), &Form2); Application->Run(); } catch (Exception &exception) { Application->ShowException(&exception); } return 0; } //--------------------------------------------------------------------------- // Заголовочный файл Unit1.H с объявлением класса формы Form1 //--------------------------------------------------------------------------- #ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include <Menus.hpp> #include <Buttons.hpp> #include <ExtCtrls.hpp> #include <ImgList.hpp> #include <jpeg.hpp> //--------------------------------------------------------------------------- class TForm1 : public TForm { __published:// IDE-managed Components TSpeedButton *SpeedButton1; TSpeedButton *SpeedButton2; TImage *logo; void __fastcall SpeedButton1Click(TObject *Sender); void __fastcall SpeedButton2Click(TObject *Sender); void __fastcall SpeedButton1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y); void __fastcall FormMouseMove(TObject *Sender, TShiftState Shift, int X, int Y); void __fastcall SpeedButton2MouseMove(TObject *Sender, TShiftState Shift, int X, int Y); private:// User declarations public:// User declarations __fastcall TForm1(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif // Заголовочный файл Unit2.H с объявлением класса главной формы Form2 //--------------------------------------------------------------------------- #ifndef Unit2H #define Unit2H //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include <Buttons.hpp> #include <Menus.hpp> #include <ComCtrls.hpp> #include <Dialogs.hpp> #include <ImgList.hpp> #include <ExtCtrls.hpp> #include <ToolWin.hpp> //--------------------------------------------------------------------------- class TForm2 : public TForm { __published:// IDE-managed Components TMainMenu *MainMenu1; TMenuItem *N1; TMenuItem *N2; TMenuItem *N3; TMenuItem *N4; TSpeedButton *SpeedButton1; TTreeView *TreeView1; TMemo *Memo1; TMenuItem *N5; TMenuItem *N6; TFontDialog *FontDialog1; TSpeedButton *SpeedButton2; TSpeedButton *SpeedButton3; TFindDialog *FindDialog1; TMenuItem *N7; TMenuItem *N9; TSpeedButton *SpeedButton4; TSaveDialog *SaveDialog1; void __fastcall SpeedButton1Click(TObject *Sender); void __fastcall TreeView1DblClick(TObject *Sender); void __fastcall FormClose(TObject *Sender, TCloseAction &Action); void __fastcall N6Click(TObject *Sender); void __fastcall SpeedButton3Click(TObject *Sender); void __fastcall SpeedButton2Click(TObject *Sender); void __fastcall TreeView1KeyDown(TObject *Sender, WORD &Key, TShiftState Shift); void __fastcall Memo1KeyDown(TObject *Sender, WORD &Key, TShiftState Shift); void __fastcall N4Click(TObject *Sender); void __fastcall N3Click(TObject *Sender); void __fastcall N7Click(TObject *Sender); void __fastcall FindDialog1Find(TObject *Sender); void __fastcall N9Click(TObject *Sender); void __fastcall SpeedButton4Click(TObject *Sender); private:// User declarations public:// User declarations __fastcall TForm2(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm2 *Form2; //--------------------------------------------------------------------------- #endif // Заголовочный файл Unit3.H с объявлением класса формы Form3 //--------------------------------------------------------------------------- #ifndef Unit3H #define Unit3H //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include <ExtCtrls.hpp> #include <ImgList.hpp> #include <Buttons.hpp> //--------------------------------------------------------------------------- class TForm3 : public TForm { __published:// IDE-managed Components TSpeedButton *SpeedButton1; TLabel *Label1; TLabel *Label2; TLabel *Label3; TLabel *Label4; void __fastcall SpeedButton1Click(TObject *Sender); private:// User declarations public:// User declarations __fastcall TForm3(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm3 *Form3; //--------------------------------------------------------------------------- #endif // Заголовочный файл Unit4.H с объявлением класса формы Form4 //--------------------------------------------------------------------------- #ifndef Unit4H #define Unit4H //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include <ExtCtrls.hpp> #include <ImgList.hpp> #include <Buttons.hpp> //--------------------------------------------------------------------------- class TForm4 : public TForm { __published:// IDE-managed Components TSpeedButton *SpeedButton1; TLabel *Label1; TLabel *Label2; TLabel *Label3; TLabel *Label4; TLabel *Label5; void __fastcall SpeedButton1Click(TObject *Sender); private:// User declarations public:// User declarations __fastcall TForm4(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TForm4 *Form4; //--------------------------------------------------------------------------- #endif // Файл Unit1.cpp для формы Form1 //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" #include "Unit2.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; int c,c1; bool fl,fl2; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::SpeedButton1Click(TObject *Sender) { Form2->Visible=true; Form1->Visible=false; } //--------------------------------------------------------------------------- void __fastcall TForm1::SpeedButton2Click(TObject *Sender) { Application->Terminate(); } //--------------------------------------------------------------------------- void __fastcall TForm1::SpeedButton1MouseMove(TObject *Sender, 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(); } //--------------------------------------------------------------------------- Приложение Б Диаграмма вариантов использования
Страницы: 1, 2, 3
|