?? unit1.~cpp
字號:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <dos.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "A0Lib_OCX"
#pragma link "A1Lib_OCX"
#pragma link "HUFCTRLLib_OCX"
#pragma link "HUFDYNAMICAUTOSENSELib_OCX"
#pragma link "HUFDYNAMICGLOBALLib_OCX"
#pragma link "HUFSTATICLib_OCX"
#pragma link "LZWLib_OCX"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
this->RadioButton1->Checked = true;
this->RadioButton1->OnClick;
this->RadioButton3->Checked =true;
this->RadioButton3->OnClick;
this->RadioButton6->Checked =true;
this->RadioButton6->OnClick;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton1Click(TObject *Sender)
{
Form1->OpenDialog1->Filter = "文本文件 (*.txt)|*.TXT|word文檔 (*.doc)|*.DOC|圖象文件 (*.bmp;*.jpeg;*.gif)|*.BMP;*.JPEG;*.GIF|所有文件 (*.*)|*.*";
Form1->SaveDialog1->Filter = "壓縮文件 (*.cpr)|*.CPR|所有文件 (*.*)|*.*";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
OpenDialog1->Title = "源文件";
if(OpenDialog1->Execute())
{
Form1->Edit1->Text = OpenDialog1->FileName;
};
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
SaveDialog1->Title ="目標文件";
if (SaveDialog1->Execute())
{
Form1->Edit2->Text = SaveDialog1->FileName;
if(Form1->RadioButton1->Checked)
{
Form1->Edit2->Text = ChangeFileExt(Form1->Edit2->Text,".cpr");
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton2Click(TObject *Sender)
{
Form1->OpenDialog1->Filter = "壓縮文件 (*.cpr)|*.CPR|所有文件 (*.*)|*.*";
Form1->SaveDialog1->Filter = "所有文件 (*.*)|*.*";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton7Click(TObject *Sender)
{
this->RadioButton6->Enabled =true;
this->RadioButton9->Enabled =true;
this->GroupBox3->Enabled =true;
this->RadioButton6->Checked =true;
this->RadioButton6->OnClick;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton9Click(TObject *Sender)
{
this->Edit3->Enabled =true;
this->Label3->Enabled =true;
this->Hufdynamicautosense1->AutoSelectStep = false;
this->Hufdynamicglobal1->AutoSelectStep =false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton6Click(TObject *Sender)
{
this->Edit3->Enabled =false;
this->Label3->Enabled =false;
this->Hufdynamicautosense1->AutoSelectStep = true;
this->Hufdynamicglobal1->AutoSelectStep =true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton8Click(TObject *Sender)
{
this->RadioButton6->Enabled =true;
this->RadioButton9->Enabled =true;
this->GroupBox3->Enabled =true;
this->RadioButton6->Checked =true;
this->RadioButton6->OnClick;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton3Click(TObject *Sender)
{
this->RadioButton6->Enabled =false;
this->RadioButton9->Enabled =false;
this->GroupBox3->Enabled =false;
this->Edit3->Enabled =false;
this->Label3->Enabled =false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton5Click(TObject *Sender)
{
this->RadioButton6->Enabled =false;
this->RadioButton9->Enabled =false;
this->GroupBox3->Enabled =false;
this->Edit3->Enabled =false;
this->Label3->Enabled =false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton4Click(TObject *Sender)
{
this->RadioButton6->Enabled =false;
this->RadioButton9->Enabled =false;
this->GroupBox3->Enabled =false;
this->Edit3->Enabled =false;
this->Label3->Enabled =false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int flag;
long scrlen,dstlen,time_used;
double ratio;
struct time t,priocomp,aftercomp;
AnsiString scrfile,dstfile,tempstr;
if (Form1->RadioButton1->Checked)
{
if(!FileExists(Form1->Edit1->Text))
{
ShowMessage("源文件不存在!");
return;
}
if(FileExists(Form1->Edit2->Text))
{
flag=Application->MessageBox("目標文件已存在!替換它嗎?", "警告!",MB_OKCANCEL);
if(flag==IDCANCEL)
{
ShowMessage("操作取消!壓縮未完成!");
return;
}
}
if(Form1->RadioButton3->Checked)
{
Form1->Lzss1->sourcefile =Form1->Edit1->Text;
Lzss1->destfile =Form1->Edit2->Text;
gettime(&priocomp);
flag=Lzss1->compress();
gettime(&aftercomp);
scrfile = Lzss1->sourcefile;
dstfile = Lzss1->destfile ;
}
else
{
if(Form1->RadioButton4->Checked)
{
Form1->Hufctrl1->Sourcefile =Form1->Edit1->Text;
Hufctrl1->Destfile =Form1->Edit2->Text;
gettime(&priocomp);
flag=Hufctrl1->compress();
gettime(&aftercomp);
scrfile = Hufctrl1->Sourcefile;
dstfile = Hufctrl1->Destfile;
}
else
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -