//------------------------------------------------------------------------------
//Splash.pas,Splash.dfm
//闪现窗体,并联接数据库
//------------------------------------------------------------------------------
unit Splash;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, Forms,
Dialogs, ExtCtrls,Global,ADODB, MainDM, Graphics, StdCtrls;
type
TSplashForm = class(TForm)
dlgOpen: TOpenDialog;
imgBack: TImage;
private
{ Private declarations }
public
{ Public declarations }
end;
function ShowSplashForm:boolean;
var
SplashForm: TSplashForm;
implementation
{$R *.dfm}
function ShowSplashForm:boolean;
//显示闪现窗口,同时连接数据库,如果失败则选择其它数据库
function OpenDBFile:boolean;
//选择数据库
begin
result:=true;
SplashForm.dlgopen.FileName:=sDataBaseName;
if SplashForm.dlgopen.Execute then
sDataBaseName:=SplashForm.dlgopen.FileName
else
result:=false;
Application.ProcessMessages;
end;
begin
Screen.Cursor:=crHourGlass;
result:=true;
SplashForm:=TSplashForm.Create(Application);
SplashForm.Show;
SplashForm.Refresh;
if length(sDataBaseName)=0 then
sDataBaseName:=ExtractFilePath(application.ExeName)
+SDefDataBaseName;
if not FileExists(sDataBaseName) then
result:=OpenDBFile;
while result do
try
MainDMForm:=TMainDMForm.Create(Application);//MainDMForm为数据窗体
with MainDMForm do
begin
if CNMain.Connected then CNMain.Close;//CNMain为ADOConnection
//SConnectionString='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;Jet OLEDB
atabase Password=%s;';
CNMain.ConnectionString:=format(
SConnectionString,[sDataBaseName,GetPassWord]);
CNMain.Open;
end; //with
except
msgbox(SEOpenDBFile,SAppName,mb_iconstop);
result:=OpenDBFile;
end; //try
if not result then exit;
Application.ProcessMessages;
// Sleep(3000);
Screen.Cursor:=crDefault;
SplashForm.Close;
SplashForm.Free;
end;
end.