home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 May / VPR9705A.ISO / VPR_DATA / PROGRAM / CBTRIAL / SETUP / DATA.Z / MDIMAIN.CPP < prev    next >
C/C++ Source or Header  |  1997-02-14  |  7KB  |  195 lines

  1. //----------------------------------------------------------------------------
  2. //Borland C++Builder
  3. //Copyright (c) 1987, 1997 Borland International Inc. All Rights Reserved.
  4. //----------------------------------------------------------------------------
  5. //---------------------------------------------------------------------------
  6. #include <vcl.h>
  7. #pragma hdrstop
  8.  
  9. #include "mdimain.h"
  10. #include "mdichild.h"
  11. #include "about.h"
  12. //---------------------------------------------------------------------------
  13. #pragma resource "*.dfm"
  14. TMainForm *MainForm;
  15. //---------------------------------------------------------------------------
  16. __fastcall TMainForm::TMainForm(TComponent* Owner)
  17.     : TForm(Owner)
  18. {
  19. }
  20. //---------------------------------------------------------------------------
  21. void __fastcall TMainForm::About1Click(TObject *Sender)
  22. {
  23.   TAboutBox* AboutBox = new TAboutBox(this);
  24.   AboutBox->ShowModal();
  25.   delete AboutBox;
  26. }
  27. //---------------------------------------------------------------------------
  28. void __fastcall TMainForm::ArrangeIcons1Click(TObject *Sender)
  29. {
  30.   ArrangeIcons();
  31. }
  32. //---------------------------------------------------------------------------
  33. void __fastcall TMainForm::Cascade1Click(TObject *Sender)
  34. {
  35.   Cascade();
  36. }
  37. //---------------------------------------------------------------------------
  38. void __fastcall TMainForm::Close1Click(TObject *Sender)
  39. {
  40.   if (ActiveMDIChild != NULL)
  41.     this->ActiveMDIChild->Close();
  42. }
  43. //---------------------------------------------------------------------------
  44. void __fastcall TMainForm::CloseAll1Click(TObject *Sender)
  45. {
  46.   int i;
  47.   for (i = 0; i < MDIChildCount; i++)
  48.       MDIChildren[i]->Close();
  49. }
  50. //---------------------------------------------------------------------------
  51. void __fastcall TMainForm::CopyButtonClick(TObject *Sender)
  52. {
  53.   if (this->ActiveMDIChild != NULL)
  54.     ((TMDIChildForm*)this->ActiveMDIChild)->OleContainer1->Copy();
  55. }
  56. //---------------------------------------------------------------------------
  57. void __fastcall TMainForm::CutButtonClick(TObject *Sender)
  58. {
  59.   if (ActiveMDIChild != NULL){
  60.       TMDIChildForm* ch = (TMDIChildForm*) this->ActiveMDIChild;
  61.       ch->OleContainer1->Copy();
  62.       ch->OleContainer1->DestroyObject();
  63.       CutButton->Enabled = False;
  64.       CopyButton->Enabled = False;
  65.       PasteButton->Enabled = True;
  66.   }
  67. }
  68. //---------------------------------------------------------------------------
  69. void __fastcall TMainForm::Exit1Click(TObject *Sender)
  70. {
  71.   Close();
  72. }
  73. //---------------------------------------------------------------------------
  74. void __fastcall TMainForm::File1Click(TObject *Sender)
  75. {
  76.   if (this->ActiveMDIChild != NULL){
  77.     TMDIChildForm* ch = (TMDIChildForm*) this->ActiveMDIChild;
  78.     Save1->Enabled = ch->OleContainer1->Modified;
  79.     SaveAs1->Enabled = ch->OleContainer1->Modified;
  80.   }
  81.   else {
  82.     Save1->Enabled = False;
  83.     SaveAs1->Enabled = False;
  84.   }
  85.   Close2->Enabled = this->ActiveMDIChild != NULL;
  86.   CloseAll1->Enabled = this->ActiveMDIChild != NULL;
  87. }
  88. //---------------------------------------------------------------------------
  89. void __fastcall TMainForm::LinkButtonClick(TObject *Sender)
  90. {
  91.   TMDIChildForm* MDIChild;
  92.  
  93.   if (ActiveMDIChild == NULL) {
  94.  
  95.     if (OpenDialog1->Execute()){
  96.  
  97.       MDIChild = new TMDIChildForm(this);
  98.       MDIChild->CreateFromFile(OpenDialog1->FileName, True);
  99.     }
  100.   }
  101.   else{
  102.     MDIChild = (TMDIChildForm*) this->ActiveMDIChild;
  103.     if ((MDIChild->OleContainer1->State == osEmpty) ||
  104.         (MessageDlg("Replace existing object?",
  105.                     mtConfirmation,
  106.                     TMsgDlgButtons() << mbOK << mbCancel,
  107.                     0) == mrOk))
  108.       if (OpenDialog1->Execute())
  109.         MDIChild->CreateFromFile(OpenDialog1->FileName, True);
  110.   }
  111. }
  112. //---------------------------------------------------------------------------
  113. void __fastcall TMainForm::FormCreate(TObject *Sender)
  114. {
  115.   Application->OnHint = ShowHint;
  116. }
  117. //---------------------------------------------------------------------------
  118. void __fastcall TMainForm::New1Click(TObject *Sender)
  119. {
  120.   MDIChildForm = new TMDIChildForm(this);
  121.   MDIChildForm->InsertObject1Click(Sender);
  122.   if (MDIChildForm->OleContainer1->NewInserted)
  123.     MDIChildForm->OleContainer1->DoVerb(ovPrimary);
  124. }
  125. //---------------------------------------------------------------------------
  126. void __fastcall TMainForm::Open1Click(TObject *Sender)
  127. {
  128.     if (OpenDialog1->Execute()){
  129.         TMDIChildForm* ch = new TMDIChildForm(this);
  130.           ch->CreateFromFile(OpenDialog1->FileName, False);
  131.       CutButton->Enabled = True;
  132.       CopyButton->Enabled = True;
  133.     }
  134. }
  135. //---------------------------------------------------------------------------
  136. void __fastcall TMainForm::Paste1Click(TObject *Sender)
  137. {
  138.   if (ActiveMDIChild == NULL)
  139.     return;
  140.  
  141.   TMDIChildForm* ch = (TMDIChildForm*) this->ActiveMDIChild;
  142.     if ((ch->OleContainer1->State == osEmpty) ||
  143.         (MessageDlg("Replace existing object?",
  144.                     mtConfirmation,
  145.                     TMsgDlgButtons() << mbOK << mbCancel,
  146.                     0) == mrOk)){
  147.         ch->OleContainer1->Paste();
  148.         CutButton->Enabled = True;
  149.         CopyButton->Enabled = True;
  150.     }
  151. }
  152. //---------------------------------------------------------------------------
  153. void __fastcall TMainForm::Save1Click(TObject *Sender)
  154. {
  155.   TMDIChildForm* ch = (TMDIChildForm*) this->ActiveMDIChild;
  156.  
  157.   if (((ch->FileName.Length()) == 0) || (Sender == SaveAs1)) {
  158.     if (SaveDialog1->Execute())
  159.       ch->SaveFile(SaveDialog1->FileName);
  160.   }
  161.   else
  162.     ch->SaveFile(SaveDialog1->FileName);
  163. }
  164. //---------------------------------------------------------------------------
  165. void __fastcall TMainForm::Tile1Click(TObject *Sender)
  166. {
  167.   TileMode = tbHorizontal;
  168.   Tile();
  169. }
  170. //---------------------------------------------------------------------------
  171. void __fastcall TMainForm::TileHorizontally1Click(TObject *Sender)
  172. {
  173.   TileMode = tbVertical;
  174.   Tile();
  175. }
  176. //---------------------------------------------------------------------------
  177. void __fastcall TMainForm::Window2Click(TObject *Sender)
  178. {
  179.   Tile1->Enabled               = (ActiveMDIChild != NULL);
  180.   TileHorizontally1->Enabled   = (ActiveMDIChild != NULL);
  181.   Cascade1->Enabled            = (ActiveMDIChild != NULL);
  182.   ArrangeIcons1->Enabled       = (ActiveMDIChild != NULL);
  183. }
  184. //---------------------------------------------------------------------
  185. void __fastcall TMainForm::ShowHint(TObject *Sender)
  186. {
  187.   StatusBar->Panels->Items[0]->Text = Application->Hint;
  188. }
  189. //---------------------------------------------------------------------
  190. void __fastcall TMainForm::Object2Click(TObject *Sender)
  191. {
  192.   if ((this->ActiveMDIChild) != NULL)
  193.     ((TMDIChildForm*) this->ActiveMDIChild)->OleContainer1->ObjectPropertiesDialog();
  194. }//---------------------------------------------------------------------------
  195.