📄 pathsetup.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "ShFwMain.h"
#include "PathSetup.h"
#include <IniFiles.hpp>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TPathForm *PathForm;
//---------------------------------------------------------------------------
__fastcall TPathForm::TPathForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TPathForm::FormCreate(TObject *Sender)
{
AnsiString def,IniFileName;
MainForm->ADOConnection1->Close();
IniFileName = MainForm->CurDir + "\\Config.ini";
TIniFile *IniFile = new TIniFile( IniFileName.c_str() );
MainForm->MDBPATH=IniFile->ReadString( "PathInfo", "dbpath", def );
MainForm->MyGsMc = IniFile->ReadString( "PathInfo", "GsMc", def);
MainForm->MyCxSum = IniFile->ReadInteger( "PathInfo", "CxSum", 90);
delete IniFile;
Edit1->Text = MainForm->MDBPATH;
Edit2->Text = MainForm->MyGsMc;
Label4->Caption = String(MainForm->MyCxSum);
TrackBar1->Position = MainForm->MyCxSum / 30;
}
//---------------------------------------------------------------------------
void __fastcall TPathForm::BitBtn2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TPathForm::BitBtn1Click(TObject *Sender)
{
if( FileExists(Edit1->Text)== false ) {
Application->MessageBox("指定的数据源路径无效!","警告",MB_OK+MB_ICONWARNING);
Abort();
}
if( Edit2->Text.Trim()=="" ) {
Application->MessageBox("专业名称不能为空!","警告",MB_OK+MB_ICONWARNING);
Abort();
}
AnsiString IniFileName = MainForm->CurDir + "\\Config.ini";
TIniFile *IniFile = new TIniFile( IniFileName.c_str() );
IniFile->WriteString( "PathInfo", "dbpath", Edit1->Text.c_str() );
IniFile->WriteString( "PathInfo", "GsMc", Edit2->Text.c_str() );
IniFile->WriteInteger( "PathInfo", "CxSum", Label4->Caption.ToInt());
MainForm->MDBPATH = Edit1->Text;
MainForm->MyGsMc = Edit2->Text;
MainForm->MyCxSum = Label4->Caption.ToInt();
MainForm->ADOConnection1->ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+MainForm->MDBPATH+";Mode=ReadWrite;Persist Security Info=False";
Close();
}
//---------------------------------------------------------------------------
void __fastcall TPathForm::BitBtn3Click(TObject *Sender)
{
if( OpenDialog1->Execute())
Edit1->Text = OpenDialog1->FileName;
}
//---------------------------------------------------------------------------
void __fastcall TPathForm::TrackBar1Change(TObject *Sender)
{
Label4->Caption = String( TrackBar1->Position * 30 );
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -