⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ofdemounit.pas

📁 漏洞扫描系列中HB Network Scanner 测试用练习代码
💻 PAS
字号:
unit OFDemoUnit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ObjectsForm, ExtCtrls, epHint, MediaLib;

type
  TForm1 = class(TForm)
    Player: TepObjectsForm;
    Timer1: TTimer;
    epHint1: TepHint;
    epBitmap1: TepBitmap;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure PlayerMouseDownEvent(IDCode, X, Y: Integer;
      ObjectRect: TRect; Button: TMouseButton);
    procedure PlayerTrackBarChangeValueEvent(IDCode, Value: Integer);
    procedure PlayerMouseUpEvent(IDCode, X, Y: Integer; ObjectRect: TRect;
      Button: TMouseButton);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
var
  Pause: Boolean;

procedure TForm1.FormCreate(Sender: TObject);
begin
  with Player do
  begin
    // Play Buttons
    SelectButtonObject(1, Rect(36, 131, 58, 143), Rect(38, 55, 60, 67),
                       Rect(38, 32, 60, 44), -1, True, 'Jump to left');
    SelectButtonObject(2, Rect(65, 131, 87, 143), Rect(67, 55, 89, 67),
                       Rect(67, 32, 89, 44), 1, True, 'Play');
    SelectButtonObject(3, Rect(93, 131, 115, 143), Rect(95, 55, 117, 67),
                       Rect(95, 32, 117, 44), 1, True, 'Stop');
    SelectButtonObject(4, Rect(122, 131, 144, 143), Rect(124, 55, 146, 67),
                       Rect(124, 32, 146, 44), 1, True, 'Pause');
    SelectButtonObject(5, Rect(150, 131, 172, 143), Rect(152, 55, 174, 67),
                       Rect(152, 32, 174, 44), -1, True, 'Jump to right');

    SelectButtonObject(6, Rect(357, 48, 370, 59), Rect(245, 55, 258, 66),
                       NullRect, -1, True, 'Play list');

    // Switches
    SelectSwitchObject(11, Rect(32, 160, 97, 177), Rect(244, 30, 309, 47),
                       swOff, -1, '');

    SelectSwitchObject(12, Rect(112, 160, 178, 178), Rect(324, 30, 390, 48),
                       swOff, -1, '');
    //  Show Activate
    SelectShowFormActivateObject(21, Rect(60, 7, 339, 22), Rect(60, 7, 339, 22),
                                 True, True, 'ExtraPack - v. 1.3' + #13 +
                                 'TepObjectsForm - Demo');
    // TrackBars
    SelectTrackBarObject(31, tkHorizontal, Rect(182, 89, 330, 104),
                         Rect(187, 31, 200, 42), Rect(210, 31, 223, 42),
                         Point(193, 97), Point(320, 97), 0, 20, 10, True, '');
    SelectTrackBarObject(32, tkHorizontal, Rect(182, 121, 330, 137),
                         Rect(187, 31, 200, 42), Rect(210, 31, 223, 42),
                         Point(193, 129), Point(320, 129), 0, 20, 10, True, '');
    SelectTrackBarObject(33, tkHorizontal, Rect(184, 150, 376, 170),
                         Rect(187, 52, 213, 68), Rect(215, 52, 241, 68),
                         Point(204, 162), Point(357, 162), 0, 100, 0, False,
                         'Current position');
    // App Buttons
    SelectButtonObject(41, Rect(13, 9, 45, 22), Rect(13, 9, 45, 22),
                       NullRect, -1, True, 'Minimize');
    SelectButtonObject(42, Rect(355, 9, 388, 22), Rect(355, 9, 388, 22),
                       NullRect, -1, True, 'Close');
    // ProgressBars
    SelectProgressBarObject(51, bkVertical,
                            Rect(37, 78, 40, 106), Rect(15, 27, 18, 55),
                            0, 100, 0, '');

    SelectProgressBarObject(52, bkVertical,
                            Rect(43, 78, 46, 106), Rect(15, 27, 18, 55),
                            0, 100, 0, '');
    SelectProgressBarObject(53, bkVertical,
                            Rect(49, 78, 52, 106), Rect(15, 27, 18, 55),
                            0, 100, 0, '');

    SelectProgressBarObject(54, bkVertical,
                            Rect(55, 78, 58, 106), Rect(15, 27, 18, 55),
                            0, 100, 0,'');

    SelectProgressBarObject(55, bkVertical,
                            Rect(61, 78, 64, 106), Rect(15, 27, 18, 55),
                            0, 100, 0, '');

    SelectProgressBarObject(56, bkVertical,
                            Rect(67, 78, 70, 106), Rect(15, 27, 18, 55),
                            0, 100, 0, '');

    SelectProgressBarObject(57, bkVertical,
                            Rect(73, 78, 76, 106), Rect(15, 27, 18, 55),
                            0, 100, 0, '');

    SelectProgressBarObject(58, bkVertical,
                            Rect(79, 78, 82, 106), Rect(15, 27, 18, 55),
                            0, 100, 0, '');

    // Labels
    SelectLabelObject(61, Rect(36, 47, 116, 80), Point(4, 4),
                     15, 21,
                      0, 0, 'STOP3', 'Display');

    SelectLabelObject(62, Rect(94, 86, 175, 107), Point(4, 26),
                     15, 21,
                      1, 1, '00:00', 'Time');

    SelectLabelObject(63, Rect(195, 44, 354, 64), Point(4, 4),
                      15, 21,
                      0, 1, 'TECHDANCE1', 'File name');


    // Animates
    SelectAnimateObject(71, Rect(159, 47, 174, 66), Point(262, 52), 15, 19, 2,
                        '');
    AnimateTimerSetInterval(500);
    //
    Player.ButtonSetDown(3, True);
  end;
  Pause := False;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  i: Integer;
begin
  with Player do
  begin
    for i := 51 to 58 do ProgressBarSetValue(i, Random(100));
    TrackBarSetValue(33, TrackBarGetValue(33) + 1);
  end;
end;

procedure TForm1.PlayerMouseDownEvent(IDCode, X, Y: Integer;
  ObjectRect: TRect; Button: TMouseButton);
var
  i: Integer;
begin
  if Button = mbLeft then
  case IDCode of
    2:
      begin
        Timer1.Enabled := True;
        if Player.TrackBarGetValue(33) = 100
        then
          Player.TrackBarSetValue(33, 0);
        Pause := True;
        Player.LabelSetCaption(61, 'PLAY');
        Player.AnimateObjectSetActive(71, True);
      end;
    3: begin
         Timer1.Enabled := False;
         for i := 51 to 58 do
           Player.ProgressBarSetValue(i, 0);
         Pause := False;
         Player.LabelSetCaption(61, 'STOP');
         Player.AnimateObjectSetActive(71, False);
         Player.AnimateObjectSetFrame(71, 0);
       end;
    4: begin
         if Timer1.Enabled
         then
           begin
             Timer1.Enabled := False;
             for i := 51 to 58 do
               Player.ProgressBarSetValue(i, 0);
             Pause := True;
             Player.LabelSetCaption(61, 'PAUSE');
             Player.AnimateObjectSetActive(71, False);
             Player.AnimateObjectSetFrame(71, 0);
           end
         else
           if Pause
           then
             begin
               Player.ButtonSetDown(2, True);
               Timer1.Enabled := True;
               Player.LabelSetCaption(61, 'PLAY');
               Player.AnimateObjectSetActive(71, True);
             end;
       end;
    1: Player.TrackBarSetValue(33, Player.TrackBarGetValue(33) - 10);
    5: Player.TrackBarSetValue(33, Player.TrackBarGetValue(33) + 10);
  end;
end;

procedure TForm1.PlayerTrackBarChangeValueEvent(IDCode, Value: Integer);
var
  i: Integer;
  S: String;
begin
   case IDCode of
     33: begin
           if Value = 100
           then
             begin
               if Player.SwitchGetState(11) = swOff
               then
                 begin
                   Timer1.Enabled := False;
                   for i := 51 to 58 do
                     Player.ProgressBarSetValue(i, 0);
                   Player.ButtonSetDown(3, True);
                   Player.LabelSetCaption(61, 'STOP');
                   Player.AnimateObjectSetActive(71, False);
                   Player.AnimateObjectSetFrame(71, 0);
                 end
               else
                 Player.TrackBarSetValue(33, 0);
           end;
           S := IntToStr(Round(35 * Value / 100));
           if Length(S) = 1 then S := '0'+S;
           Player.LabelSetCaption(62, '00:' + S);
         end;
   end;
end;

procedure TForm1.PlayerMouseUpEvent(IDCode, X, Y: Integer;
  ObjectRect: TRect; Button: TMouseButton);
begin
  if Button = mbLeft then
  case IDCode of
    41: Application.Minimize;
    42: Close;
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -