#include <vcl.h>
#include <stdio.h>
#pragma hdrstop
#include "Unit06.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//--------------------------------------------------------------------
void __fastcall TForm1::ScrollBar1Change(TObject *Sender)
{
    RadioGroup1->ItemIndex = ScrollBar1->Position;
}
//--------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
     PopupMenu1->AutoPopup = FALSE;
}
//--------------------------------------------------------------------
void __fastcall TForm1::Form1MouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
     PopupMenu1->Popup(X, Y);
}
//--------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  int iFileHandle;
  int iFileLength;
  char *Buffer;
      iFileHandle = FileOpen(Edit1->Text.c_str(), fmOpenRead);
      iFileLength = FileSeek(iFileHandle, 0, 2);
      if(iFileLength == -1)
        {
         Application->MessageBox("Nie można otworzy pliku.",
                                  "Błąd pliku", IDOK);
        }
         else
           {
            FileSeek(iFileHandle, 0, 0);
            Buffer = new char[iFileLength+1];
            FileRead(iFileHandle, Buffer, iFileLength);
            FileClose(iFileHandle);
            Memo1->Lines->Append(Buffer);
            delete [] Buffer;
           }
}
//--------------------------------------------------------------------
void __fastcall TForm1::ApplicationCloseClick(TObject *Sender)
{
    switch(MessageBox(NULL, " Działanie aplikacji zostanie"
                      " zakończone.", "Uwaga!",
                       MB_YESNOCANCEL | MB_ICONQUESTION))
        {
         case ID_YES     : Application->Terminate();
         case ID_CANCEL : Abort();
        }

}
//--------------------------------------------------------------------
void __fastcall TForm1::CheckBox1Click(TObject *Sender)
{
   if (CheckBox1->State == TRUE)
     {
      Memo1->Font->Name = fsItalic;
      Memo1->Font->Color = clMaroon;
     }
}
//--------------------------------------------------------------------
void __fastcall TForm1::CheckBox2Click(TObject *Sender)
{
   if (CheckBox2->Checked)
     {
      Memo1->Font->Name = fsItalic;
      Memo1->Font->Color = clBlue;
     }
}
//--------------------------------------------------------------------
void __fastcall TForm1::RadioButton1Click(TObject *Sender)
{
     Memo1->Color = clYellow;
}
//-------------------------------------------------------------------
void __fastcall TForm1::RadioButton2Click(TObject *Sender)
{
     Memo1->Color = clAqua;
}
//--------------------------------------------------------------------
void __fastcall TForm1::RadioButton3Click(TObject *Sender)
{
    Memo1->Color = clWhite;
}
//--------------------------------------------------------------------
void __fastcall TForm1::RadioGroup1Click(TObject *Sender)
{
    if (RadioGroup1->ItemIndex == 0)
      Memo1->Color = clWhite;
    if (RadioGroup1->ItemIndex == 1)
      Memo1->Color = clAqua;
    if (RadioGroup1->ItemIndex == 2)
      Memo1->Color = clYellow;
}
//--------------------------------------------------------------------
void __fastcall TForm1::BlueClick(TObject *Sender)
{
    Form1->Color = clBlue;
}
//--------------------------------------------------------------------
void __fastcall TForm1::RedClick(TObject *Sender)
{
     Form1->Color = clRed;
}
//--------------------------------------------------------------------
void __fastcall TForm1::GreenClick(TObject *Sender)
{
     Form1->Color = clGreen;
}
//--------------------------------------------------------------------
void __fastcall TForm1::BtnFaceClick(TObject *Sender)
{
    Form1->Color = clBtnFace;
}
//--------------------------------------------------------------------

