如何做启动窗体 由于我的我系统启动比较慢,我想在系统运行的时候,先出现一个提示“系统加载中信息”,然后再进入我的系统,不知道有谁这方便的经验,能帮助我一下,在等待中、、、、、、 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Delphi--软件启动画面中启动状态的显在flashfrm窗體中unit flash;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, Gauges;type TFlashfrm = class(TForm) Image1: TImage; Gauge1: TGauge; Label1: TLabel; procedure FormCreate(Sender: TObject); private { Private declarations } procedure RepaintForm; public { Public declarations } procedure BeginLoad; procedure EndLoad; procedure UpdateLoadStatus(const AStatusText: string; AProgress: Integer); end;var Flashfrm: TFlashfrm;implementation{$R *.dfm}procedure tFlashfrm.BeginLoad;begin label1.Caption := '正在初始化程序...'; Gauge1.Progress := 0; RepaintForm;end;procedure tFlashfrm.EndLoad;begin label1.Caption := '初始化完成'; Gauge1.Progress := 100; RepaintForm;end;procedure tFlashfrm.RepaintForm;begin Show; Update; Sleep(500);end;procedure tFlashfrm.UpdateLoadStatus(const AStatusText: string; AProgress: Integer);begin label1.Caption := AStatusText; Gauge1.Progress := AProgress; Sleep(500); RepaintForm;end;procedure TFlashfrm.FormCreate(Sender: TObject);begin label1.Caption := ''; Gauge1.MinValue := 0; Gauge1.MaxValue := 100;end;end.在dpr窗體中(F8進入)program Flashexe;uses Forms, Windows, Controls, Messages, flash in 'flash.pas' {Flashfrm}, Main in 'Main.pas' {Mainfrm}, frm1 in 'frm1.pas' {Frmfrm1};{$R *.res}var hMutex: THandle; FoundWnd: THandle; ModuleName: string;function EnumWndProc(hwnd: THandle; Param: Cardinal): Bool; stdcall;var ClassName, WinModuleName: string; WinInstance: THandle;begin Result := True; SetLength(ClassName, 100); GetClassName (hwnd, PChar (ClassName), Length (ClassName)); ClassName := PChar(ClassName); if ClassName = Tmainfrm.ClassName then begin SetLength(WinModuleName, 200); WinInstance := GetWindowLong(hwnd, GWL_HINSTANCE); GetModuleFileName (WinInstance, PChar (WinModuleName), Length(WinModuleName)); WinModuleName := PChar(WinModuleName); if WinModuleName = ModuleName then begin FoundWnd := Hwnd; Result := False; end; end;end;begin HMutex := CreateMutex(nil, False, 'OneCopyMutex'); if WaitForSingleObject(hMutex, 0) <> WAIT_TIMEOUT then begin Application.Initialize; Flashfrm := tFlashfrm.Create(nil); try with Flashfrm do begin BeginLoad; Application.CreateForm(TMainfrm, Mainfrm); // 加載窗體 UpdateLoadStatus('正在加載模塊1......', 10); // 加載窗體 Application.CreateForm(TFrmfrm1, Frmfrm1); UpdateLoadStatus('正在加載模塊2......', 40); // 加載窗體 UpdateLoadStatus('正在加載模塊3......', 60); // 加載窗體 UpdateLoadStatus('正在加載模塊4......', 70); // 加載窗體 UpdateLoadStatus('正在加載模塊5......', 80); // 加載窗體 UpdateLoadStatus('正在加載模塊6......', 90); // 加載窗體 Flashfrm.EndLoad; end; finally Flashfrm.Free; end; Application.Run; end else begin SetLength(ModuleName, 200); GetModuleFileName (HInstance, PChar(ModuleName), Length (ModuleName)); ModuleName := PChar(ModuleName); EnumWindows(@EnumWndProc, 0); if FoundWnd <> 0 then begin if not IsWindowVisible(FoundWnd) then PostMessage(FoundWnd, wm_App, 0, 0); SetForegroundWindow(FoundWnd); end; end;end. 窗体设置为bsnoe,放一张图片,一个timer,timer的时间由你设,事件写timer.enabled:=false;close;工程文件里写:FrmInit:=TFrmInit.Create(FrmInit); FrmInit.ShowModal;Application.CreateForm(TFrmMain, FrmMain); Application.Initialize; Application.Run; 启动界面最好放到主窗体的formcreate里面去操作,初始化完成后关闭就可以了 procedure TMainFrm.FormCreate(Sender: TObject);begin //GetConfigInfo1; try LogonFrm:=TLogonFrm.Create(Application); finally LogonFrm.ShowModal; //登录窗体, // if (ClientMyUser.cUserCode<>'') and (ClientMyUser.cPassWord<>'') then begin try Flashfrm := TFlashfrm.Create(Application); Flashfrm.Show; //启动界面,初始化的一些操作可以在他的里面做 sleep(3000); .....//初始化的操作也可以加到这里吧 finally FreeAndNil(Flashfrm); end; end; FreeAndNil(LogonFrm); end;end;说明:MainFrm是系统的主窗体.你找找以前的帖子吧,应该不少的. 打开dpr文件的代码begin Splasher:=TSplasher.Create(Application); Splasher.Show; Splasher.Update; Application.Initialize; Splasher.lblStatupInfo.Caption:='正在连接服务器,请稍后……'; Splasher.Update; Application.Title := 'xxxxxx'; Application.CreateForm(TdataMdl, dataMdl); Splasher.Update; if DataMdl.conComm.Connected then begin Application.CreateForm(TMainform, Mainform); end; Splasher.Free; Application.Run;end. 加进度条的办法:在工程启动的过程中,每加载一个窗体,就修改进度条然后刷新Splash窗体。 在DELPHI中如何定义时间 在第一天的8点 和第二天的8点之间 函数返回值的问题 简单问题 为什么ToolBar的TButton里设置了caption属性,但是没显示出来? Pipe有什么用途? dll静态调用错误 请教ADO问题 自动调整列宽 小弟想了解一下有关delphi串口编程的知识,我可是一点也不懂啊,能举个例子让我实现一下就更好了! 如何使用DATETIMEPICKER在DBGRID里输入日期? 如何判断一个 OLE字段没有内容? wwdbgrid如何显示行号
在flashfrm窗體中
unit flash;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Gauges;
type
TFlashfrm = class(TForm)
Image1: TImage;
Gauge1: TGauge;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure RepaintForm;
public
{ Public declarations }
procedure BeginLoad;
procedure EndLoad;
procedure UpdateLoadStatus(const AStatusText: string; AProgress: Integer); end;
var
Flashfrm: TFlashfrm;
implementation
{$R *.dfm}
procedure tFlashfrm.BeginLoad;
begin
label1.Caption := '正在初始化程序...';
Gauge1.Progress := 0;
RepaintForm;
end;procedure tFlashfrm.EndLoad;
begin
label1.Caption := '初始化完成';
Gauge1.Progress := 100;
RepaintForm;
end;
procedure tFlashfrm.RepaintForm;
begin
Show; Update; Sleep(500);
end;
procedure tFlashfrm.UpdateLoadStatus(const AStatusText: string; AProgress: Integer);
begin
label1.Caption := AStatusText;
Gauge1.Progress := AProgress; Sleep(500);
RepaintForm;
end;
procedure TFlashfrm.FormCreate(Sender: TObject);
begin
label1.Caption := '';
Gauge1.MinValue := 0;
Gauge1.MaxValue := 100;
end;
end.
在dpr窗體中(F8進入)
program Flashexe;
uses
Forms,
Windows,
Controls,
Messages,
flash in 'flash.pas' {Flashfrm},
Main in 'Main.pas' {Mainfrm},
frm1 in 'frm1.pas' {Frmfrm1};
{$R *.res}
var
hMutex: THandle;
FoundWnd: THandle;
ModuleName: string;function EnumWndProc(hwnd: THandle; Param: Cardinal): Bool; stdcall;
var
ClassName, WinModuleName: string;
WinInstance: THandle;
begin
Result := True;
SetLength(ClassName, 100);
GetClassName (hwnd, PChar (ClassName), Length (ClassName));
ClassName := PChar(ClassName);
if ClassName = Tmainfrm.ClassName then
begin
SetLength(WinModuleName, 200);
WinInstance := GetWindowLong(hwnd, GWL_HINSTANCE);
GetModuleFileName (WinInstance, PChar (WinModuleName),
Length(WinModuleName));
WinModuleName := PChar(WinModuleName);
if WinModuleName = ModuleName then
begin
FoundWnd := Hwnd;
Result := False;
end;
end;
end;begin
HMutex := CreateMutex(nil, False, 'OneCopyMutex');
if WaitForSingleObject(hMutex, 0) <> WAIT_TIMEOUT then
begin
Application.Initialize;
Flashfrm := tFlashfrm.Create(nil);
try
with Flashfrm do
begin
BeginLoad;
Application.CreateForm(TMainfrm, Mainfrm);
// 加載窗體
UpdateLoadStatus('正在加載模塊1......', 10);
// 加載窗體
Application.CreateForm(TFrmfrm1, Frmfrm1);
UpdateLoadStatus('正在加載模塊2......', 40);
// 加載窗體
UpdateLoadStatus('正在加載模塊3......', 60);
// 加載窗體
UpdateLoadStatus('正在加載模塊4......', 70);
// 加載窗體
UpdateLoadStatus('正在加載模塊5......', 80);
// 加載窗體
UpdateLoadStatus('正在加載模塊6......', 90);
// 加載窗體
Flashfrm.EndLoad;
end;
finally
Flashfrm.Free;
end;
Application.Run;
end
else
begin
SetLength(ModuleName, 200);
GetModuleFileName (HInstance, PChar(ModuleName), Length (ModuleName));
ModuleName := PChar(ModuleName);
EnumWindows(@EnumWndProc, 0);
if FoundWnd <> 0 then
begin
if not IsWindowVisible(FoundWnd) then
PostMessage(FoundWnd, wm_App, 0, 0);
SetForegroundWindow(FoundWnd);
end;
end;
end.
FrmInit:=TFrmInit.Create(FrmInit);
FrmInit.ShowModal;
Application.CreateForm(TFrmMain, FrmMain);
Application.Initialize;
Application.Run;
procedure TMainFrm.FormCreate(Sender: TObject);
begin
//GetConfigInfo1;
try
LogonFrm:=TLogonFrm.Create(Application);
finally
LogonFrm.ShowModal; //登录窗体,
// if (ClientMyUser.cUserCode<>'') and (ClientMyUser.cPassWord<>'') then
begin
try
Flashfrm := TFlashfrm.Create(Application);
Flashfrm.Show; //启动界面,初始化的一些操作可以在他的里面做
sleep(3000);
.....//初始化的操作也可以加到这里吧
finally
FreeAndNil(Flashfrm);
end;
end;
FreeAndNil(LogonFrm);
end;
end;说明:MainFrm是系统的主窗体.你找找以前的帖子吧,应该不少的.
begin
Splasher:=TSplasher.Create(Application);
Splasher.Show;
Splasher.Update;
Application.Initialize;
Splasher.lblStatupInfo.Caption:='正在连接服务器,请稍后……';
Splasher.Update;
Application.Title := 'xxxxxx';
Application.CreateForm(TdataMdl, dataMdl);
Splasher.Update;
if DataMdl.conComm.Connected then begin
Application.CreateForm(TMainform, Mainform);
end;
Splasher.Free;
Application.Run;
end.
在工程启动的过程中,每加载一个窗体,就修改进度条然后刷新Splash窗体。