Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
1
Добавлен:
30.05.2020
Размер:
3.6 Кб
Скачать
#include <vcl.h>
#pragma hdrstop
#include "SubUnit.h"
#include "CalculateFrac.h"
#include "Math.h"
#include "FracUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TSubForm *SubForm;
//---------------------------------------------------------------------------
__fastcall TSubForm::TSubForm(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TSubForm::Button1Click(TObject *Sender)
{
  int a,b,c,d;
  if(((Edit1->Text).Length()==0)||((Edit2->Text).Length()==0)||
     ((Edit3->Text).Length()==0)||((Edit4->Text).Length()==0))
  {
    ShowMessage("Заповніть всі поля!");
    return;
  }
  a=StrToInt(Edit1->Text);
  b=StrToInt(Edit2->Text);
  c=StrToInt(Edit3->Text);
  d=StrToInt(Edit4->Text);
  if((d==0)||(b==0))
  {
    ShowMessage("Ділення на нуль!!");
    return;
  }
  Button1->Enabled=false; Label3->Show();
  CalculateFrac *Calculate=new CalculateFrac;
  Calculate->SubFrac(a,b,c,d);
  if(Calculate->GetA()!=0)
  {
    Edit5->Show();
    Edit5->Text=IntToStr(Calculate->GetA());
  }
  if(Calculate->GetP()!=0)
  {
    Edit6->Show(); Edit7->Show(); Label6->Show();
    Edit6->Text=IntToStr(Calculate->GetP());
    Edit7->Text=IntToStr(Calculate->GetQ());
  }
  if((Calculate->GetA()==0)&&(Calculate->GetP()==0))
  {
    Edit5->Show();
    Edit5->Text="0";
  }

}
//---------------------------------------------------------------------------
void __fastcall TSubForm::FormActivate(TObject *Sender)
{
Label3->Hide(); Label6->Hide();
Edit5->Hide(); Edit6->Hide(); Edit7->Hide();
Edit1->Clear(); Edit2->Clear(); Edit3->Clear(); Edit4->Clear(); Edit5->Clear();
Edit6->Clear(); Edit7->Clear();
Button1->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TSubForm::Button2Click(TObject *Sender)
{
Label3->Hide(); Label6->Hide();
Edit5->Hide(); Edit6->Hide(); Edit7->Hide();
Edit1->Clear(); Edit2->Clear(); Edit3->Clear(); Edit4->Clear(); Edit5->Clear();
Edit6->Clear(); Edit7->Clear();
Button1->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TSubForm::Button3Click(TObject *Sender)
{
  SubForm->Close();
  MainForm->Show();
}
//---------------------------------------------------------------------------
void __fastcall TSubForm::Edit1KeyPress(TObject *Sender, char &Key)
{
  if(((Key>='0')&&(Key<='9'))||(Key==VK_BACK)||(Key=='-'))
    return;
  if(Key==VK_RETURN)
    Edit2->SetFocus();
  Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TSubForm::Edit3KeyPress(TObject *Sender, char &Key)
{
  if(((Key>='0')&&(Key<='9'))||(Key==VK_BACK)||(Key=='-'))
    return;
  if(Key==VK_RETURN)
    Edit4->SetFocus();
  Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TSubForm::Edit2KeyPress(TObject *Sender, char &Key)
{
  if(((Key>='0')&&(Key<='9'))||(Key==VK_BACK))
    return;
  if(Key==VK_RETURN)
    Edit3->SetFocus();
  Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TSubForm::Edit4KeyPress(TObject *Sender, char &Key)
{
  if(((Key>='0')&&(Key<='9'))||(Key==VK_BACK))
    return;
  if(Key==VK_RETURN)
    Button1->SetFocus();
  Key=0;
}
//---------------------------------------------------------------------------
Соседние файлы в папке Дроби
  • #
    30.05.20201.46 Кб1SortUnit.h
  • #
    30.05.2020104.52 Кб1SortUnit.obj
  • #
    30.05.20203.36 Кб1SortUnit.~cpp
  • #
    30.05.20202.89 Кб1SortUnit.~dfm
  • #
    30.05.20201.32 Кб1SortUnit.~h
  • #
    30.05.20203.6 Кб1SubUnit.cpp
  • #
    30.05.20204.45 Кб1SubUnit.dfm
  • #
    30.05.20201.65 Кб2SubUnit.h
  • #
    30.05.202052.8 Кб1SubUnit.obj
  • #
    30.05.20203.6 Кб1SubUnit.~cpp
  • #
    30.05.20204.45 Кб1SubUnit.~dfm