WelcomeFrm.pas 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. unit WelcomeFrm;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, ExtCtrls, jpeg;
  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. Result := WelcomeForm.Handle;
  31. WelcomeForm.Show;
  32. iFirstTime := GetTickCount;
  33. for I := 0 to 255 do
  34. begin
  35. if I mod 5 = 0 then
  36. begin
  37. WelcomeForm.AlphaBlendValue := I;
  38. WelcomeForm.Update;
  39. if GetTickCount - iFirstTime > MaxShowAnimateTime then
  40. Break;
  41. end;
  42. end;
  43. WelcomeForm.AlphaBlendValue := 255;
  44. SetForegroundWindow(WelcomeForm.Handle);
  45. end;
  46. procedure HideWelcome;
  47. var
  48. I: Integer;
  49. iFirstTime: Cardinal;
  50. begin
  51. if WelcomeForm = nil then
  52. Exit;
  53. iFirstTime := GetTickCount;
  54. for I := 255 downto 0 do
  55. begin
  56. if I mod 10 = 0 then
  57. begin
  58. WelcomeForm.AlphaBlendValue := I;
  59. WelcomeForm.Update;
  60. if GetTickCount - iFirstTime > MaxHideAnimateTime then
  61. Break;
  62. end;
  63. end;
  64. WelcomeForm.AlphaBlendValue := 0;
  65. WelcomeForm.Free;
  66. WelcomeForm := nil;
  67. end;
  68. end.