WelcomeFrm.pas 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. unit WelcomeFrm;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, ExtCtrls, jpeg, UtilMethods;
  6. type
  7. TWelcomeForm = class(TForm)
  8. imgWelcome: TImage;
  9. private
  10. { Private declarations }
  11. public
  12. { Public declarations }
  13. end;
  14. function ShowWelcome: THandle;
  15. procedure HideWelcome;
  16. implementation
  17. {$R *.dfm}
  18. var
  19. WelcomeForm: TWelcomeForm;
  20. const
  21. // ½¥±ä×î´óʱ¼ä£¨ºÁÃ룩
  22. MaxShowAnimateTime = 1500;
  23. MaxHideAnimateTime = 700;
  24. function ShowWelcome: THandle;
  25. var
  26. I: Integer;
  27. iFirstTime: Cardinal;
  28. begin
  29. WelcomeForm := TWelcomeForm.Create(nil);
  30. if FileExists(GetAppFilePath + 'Welcome.jpg') then
  31. WelcomeForm.imgWelcome.Picture.LoadFromFile(GetAppFilePath + 'Welcome.jpg');
  32. Result := WelcomeForm.Handle;
  33. WelcomeForm.Show;
  34. iFirstTime := GetTickCount;
  35. for I := 0 to 255 do
  36. begin
  37. if I mod 5 = 0 then
  38. begin
  39. WelcomeForm.AlphaBlendValue := I;
  40. WelcomeForm.Update;
  41. if GetTickCount - iFirstTime > MaxShowAnimateTime then
  42. Break;
  43. end;
  44. end;
  45. WelcomeForm.AlphaBlendValue := 255;
  46. Sleep(2000);
  47. SetForegroundWindow(WelcomeForm.Handle);
  48. end;
  49. procedure HideWelcome;
  50. var
  51. I: Integer;
  52. iFirstTime: Cardinal;
  53. begin
  54. if WelcomeForm = nil then
  55. Exit;
  56. iFirstTime := GetTickCount;
  57. for I := 255 downto 0 do
  58. begin
  59. if I mod 10 = 0 then
  60. begin
  61. WelcomeForm.AlphaBlendValue := I;
  62. WelcomeForm.Update;
  63. if GetTickCount - iFirstTime > MaxHideAnimateTime then
  64. Break;
  65. end;
  66. end;
  67. WelcomeForm.AlphaBlendValue := 0;
  68. WelcomeForm.Free;
  69. WelcomeForm := nil;
  70. end;
  71. end.