在Delphi程序的Project File中,一般先做进程防重入,再创建DataModule和主窗口,然后显示splash窗口并淡入淡出,最后一步显示主窗口并登录。方便以后复制^_^
var MutexHandle: THandle; //定义互斥句柄 begin { 进程防重入 } MutexHandle := CreateMutex(nil, TRUE, 'xxx'); if MutexHandle <> 0 then if GetLastError = ERROR_ALREADY_EXISTS then begin MessageBox(0, 'xx系统已经运行!', 'xx系统', MB_ICONHAND); CloseHandle(MutexHandle); Halt; end;
Application.Initialize;
frmSplash := TfrmSplash.Create(Application, True); frmSplash.Show; frmSplash.Update; sleep(1000);
Application.Title := 'xx系统'; Application.CreateForm(TdmMain, dmMain); Application.CreateForm(TfrmMain, frmMain);
{ splash窗口淡入淡出 } frmSplash.AlphaBlend := true; frmSplash.Show; frmSplash.Update; while frmSplash.AlphaBlendValue > 5 do begin frmSplash.AlphaBlendValue := frmSplash.AlphaBlendValue - 15; sleep(50); end; frmSplash.Free;
frmMain.Show; frmMain.LoginAction.Execute;
Application.Run; end. |