//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Main.h"
#include "About.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TMainForm *MainForm;
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent *Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::CreateMDIChild(String Name)
{
TMDIChild *Child;
//--- create a new MDI child window ----
Child = new TMDIChild(Application);
Child->Caption = Name;
Child->Image1->AutoSize=true;
Child->Image1->Picture->LoadFromFile(Name);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FileNew1Execute(TObject *Sender)
{
CreateMDIChild("NONAME" + IntToStr(MDIChildCount + 1));
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FileOpen1Execute(TObject *Sender)
{
if (OpenPictureDialog1->Execute())
CreateMDIChild(OpenPictureDialog1->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::HelpAbout1Execute(TObject *Sender)
{
AboutBox->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FileExit1Execute(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FileSaveItemClick(TObject *Sender)
{
TMDIChild* TheChild;
TPicture* ThePicture;
if (ActiveMDIChild)
{
TheChild=(TMDIChild*)ActiveMDIChild;
ThePicture=TheChild->Image1->Picture;
ThePicture->SaveToFile(TheChild->Caption);
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::UpdateActions( )
{
FileCloseItem->Enabled = MDIChildCount > 0;
FileSaveItem->Enabled = MDIChildCount > 0;
}