[ mdax @ 27.12.2017. 19:39 ] @
Kako može da se izvede sledeće: (koristim Delphi Tokyo) Imam formu frmMain, frmSplash i unit uConfig. Pri pokretanju programa prvo se prikazuje frmSplash. frmSplah poziva uConfig unit (proceduru ReadConfig) koji dalje vrši proveru programa i koja treba da na formu u frmSplash treba da poveća vrednost na ProgressBar-u. ========================================================================================= Code: program Test1; uses System.SysUtils, Vcl.Forms, uMain in 'uMain.pas' {frmMain}, uSplash in 'uSplash.pas' {frmSplash}, uConfig in 'uConfig.pas'; {$R *.res} var frmSplash: TfrmSplash; begin System.ReportMemoryLeaksOnShutdown := True; Application.Initialize; Application.MainFormOnTaskbar := True; // ---------------------------------------------------------------------------- // Kreiranje frmSplash forme i njeno pozivanje // ---------------------------------------------------------------------------- frmSplash := TfrmSplash.Create(nil); try frmSplash.ShowModal; finally frmSplash.Free; end; Application.CreateForm(TfrmMain, frmMain); Application.Run; end. ========================================================================================= unit uConfig; interface procedure ReadConfig; implementation uses sysutils, uSplash; procedure ReadConfig; begin if FileExists('Baza.sdb') then //Provera da li postoji Baza.sdb baza begin uSplash.frmSplash.prgBar.StepIt; end end; ========================================================================================= unit uSplash; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Imaging.pngimage, Vcl.ExtCtrls, Vcl.StdCtrls, AdvReflectionLabel, FormSize, Vcl.ComCtrls, inifiles; type TfrmSplash = class(TForm) pnl1: TPanel; pnl2: TPanel; img1: TImage; advrflctnlbl1: TAdvReflectionLabel; tmrSplashShow: TTimer; tmrSplashHide: TTimer; prgBar: TProgressBar; btn1: TButton; procedure tmrSplashShowTimer(Sender: TObject); procedure FormCreate(Sender: TObject); procedure tmrSplashHideTimer(Sender: TObject); procedure btn1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var frmSplash: TfrmSplash; implementation uses uConfig; {$R *.dfm} // Postavljamo vrednosti tmrSplashShow i tmrSplashHide objekta procedure TfrmSplash.btn1Click(Sender: TObject); begin ReadConfig; end; procedure TfrmSplash.FormCreate(Sender: TObject); begin tmrSplashShow.Enabled := True; tmrSplashShow.Interval := 10; tmrSplashHide.Enabled := False; tmrSplashHide.Interval := 10; end; // Pri zatvaranju forme koristi FadeOut efekat procedure TfrmSplash.tmrSplashHideTimer(Sender: TObject); begin if AlphaBlendValue <= 10 then begin tmrSplashShow.Enabled := False; AlphaBlendValue := 0; Self.Close; end else AlphaBlendValue := AlphaBlendValue - 5; end; // Pri prikazu forme koristi FadeIn efekat procedure TfrmSplash.tmrSplashShowTimer(Sender: TObject); begin if AlphaBlendValue >= 250 then begin tmrSplashShow.Enabled := False; AlphaBlendValue := 255; //ReadConfig; // Učitavanje konfiguracije programa (UNIT uConfig) //tmrSplashHide.Enabled := True; end else AlphaBlendValue := AlphaBlendValue + 5; end; end. end. Pri pokretanju programa javlja mi grešku: Access violation at address XXXX in module 'XXXX.exe' Read of address 000003E8. [Ovu poruku je menjao savkic dana 27.12.2017. u 22:40 GMT+1] |