MainSpF.pas
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:2k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit MainSpF;
  2. interface
  3. uses
  4.   Qt, SysUtils, Classes, QGraphics, QControls, QForms, QDialogs,
  5.   QMenus, QStdCtrls, QTypes;
  6. type
  7.   TForm1 = class(TForm)
  8.     ListBox1: TListBox;
  9.     MainMenu1: TMainMenu;
  10.     Help1: TMenuItem;
  11.     About1: TMenuItem;
  12.     File1: TMenuItem;
  13.     Exit1: TMenuItem;
  14.     procedure About1Click(Sender: TObject);
  15.     procedure FormCreate(Sender: TObject);
  16.     procedure Exit1Click(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.   public
  20.     { Public declarations }
  21.   end;
  22. var
  23.   Form1: TForm1;
  24. implementation
  25. uses AboutF;
  26. {$R *.xfm}
  27. procedure TForm1.About1Click(Sender: TObject);
  28. begin
  29.   if not Assigned (AboutBox) then
  30.     AboutBox := TAboutBox.Create (Application);
  31.   AboutBox.ShowModal;
  32. end;
  33. {function local to the unit}
  34. function IsPrime (N: LongInt): Boolean;
  35. var
  36.   Test: LongInt;
  37. begin
  38.   IsPrime := True;
  39.   for Test := 2 to N - 1 do
  40.   begin
  41.     if (N mod Test) = 0 then
  42.     begin
  43.       IsPrime := False;
  44.       break; {jump out of the for loop}
  45.     end;
  46.   end;
  47. end;
  48. procedure TForm1.FormCreate(Sender: TObject);
  49. var
  50.   I: Integer;
  51.   SplashAbout: TAboutBox;
  52. begin
  53.   // create and show the splash form
  54.   SplashAbout := TAboutBox.Create (Application);
  55.   SplashAbout.MakeSplash;
  56.   // standard code...
  57.   for I := 1 to 30000 do
  58.     if IsPrime (I) then
  59.       ListBox1.Items.Add (IntToStr (I));
  60.   // get rid of the splash form, after a while
  61.   SplashAbout.Timer1.Enabled := True;
  62. end;
  63. procedure TForm1.Exit1Click(Sender: TObject);
  64. begin
  65.   Close;
  66. end;
  67. end.