應用程式啟動時顯示無標題列 Splash 視窗,載入過程中(建立主視窗、資料模組、登入視窗等)即時更新提示文字(「正在初始化資料庫...」、「載入使用者權限...」),體驗媲美 Photoshop、Acrobat Reader。

Name := frm_Splash,BorderStyle := bsNone,BorderIcons := []。TImage:Align := alClient 載入品牌圖片。TLabel (lbl_Text):Transparent := True、字體顏色對比背景、置於適當位置。TProgressBar 顯示進度百分比。begin
Application.Initialize;
frm_Splash := Tfrm_Splash.Create(Application);
frm_Splash.Show;
frm_Splash.Update; // 強制首次繪製
Application.CreateForm(TfrmMain, frmMain);
frm_Splash.lbl_Text.Caption := '建立主視窗完成';
frm_Splash.Update;
Application.CreateForm(TfrmData, frmData);
frm_Splash.lbl_Text.Caption := '初始化資料模組';
frm_Splash.Update;
Application.CreateForm(TfrmLogin, frmLogin);
frm_Splash.lbl_Text.Caption := '載入登入介面';
frm_Splash.Update;
frm_Splash.Hide;
frm_Splash.Free; // 釋放資源
Application.Run;
end.
Update 立即處理訊息佇列並重繪失效區域,Repaint 強制同步重繪可能阻塞;此處 Update 較佳。Application.ProcessMessages 保持 UI 響應。PerMonitorV2 感知,Splash 圖片需提供多解析度或使用向量圖。// 在建立各模組前預估權重
const TotalWeight = 100;
var DoneWeight: Integer = 0;
procedure Bump(Weight: Integer; const Msg: string);
begin
Inc(DoneWeight, Weight);
frm_Splash.ProgressBar1.Position := DoneWeight * 100 div TotalWeight;
frm_Splash.lbl_Text.Caption := Msg;
frm_Splash.Update;
end;
begin
// ...
Bump(20, '載入組態檔...'); LoadConfig;
Bump(30, '連線資料庫...'); ConnectDB;
Bump(40, '快取基礎資料...'); CacheBaseData;
Bump(10, '完成');
// ...
end;