home *** CD-ROM | disk | FTP | other *** search
/ Guide To Cracking 2002 / Guide_to_Cracking_2002.iso / Programming / yPP-B-SRC.ZIP / Unit8.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2000-08-31  |  3.4 KB  |  137 lines

  1. unit Unit8;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, ExtCtrls, Buttons,d32lib;
  8.  
  9. type
  10.   Tsrform = class(TForm)
  11.     Panel1: TPanel;
  12.     Panel2: TPanel;
  13.     Panel3: TPanel;
  14.     Edit1: TEdit;
  15.     Edit2: TEdit;
  16.     SpeedButton1: TSpeedButton;
  17.     SpeedButton2: TSpeedButton;
  18.     GroupBox1: TGroupBox;
  19.     RadioButton1: TRadioButton;
  20.     RadioButton2: TRadioButton;
  21.     RadioButton3: TRadioButton;
  22.     CheckBox1: TCheckBox;
  23.     procedure FormShow(Sender: TObject);
  24.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  25.     procedure SpeedButton2Click(Sender: TObject);
  26.     procedure SpeedButton1Click(Sender: TObject);
  27.   private
  28.     { Private-Deklarationen }
  29.   public
  30.     { Public-Deklarationen }
  31.   end;
  32.  
  33. var
  34.   srform: Tsrform;
  35.  
  36. implementation
  37.  
  38. uses Unit1;
  39.  
  40. {$R *.DFM}
  41.  
  42. procedure Tsrform.FormShow(Sender: TObject);
  43. begin
  44. form1.enabled:=false;
  45. // setup the add postion
  46. if not editing then
  47.   begin
  48.   radiobutton3.checked:=true;
  49.   radiobutton3.enabled:=true;
  50.   if form1.listview1.selcount > 0 then
  51.     begin
  52.     radiobutton1.enabled:=true;
  53.     if currsel < form1.listview1.Items.Count-1 then radiobutton2.enabled:=true;
  54.     end;
  55.   end;
  56. end;
  57.  
  58. procedure Tsrform.FormClose(Sender: TObject; var Action: TCloseAction);
  59. begin
  60. form1.enabled:=true;
  61. radiobutton1.enabled:=false;
  62. radiobutton2.enabled:=false;
  63. radiobutton3.enabled:=false;
  64. checkbox1.checked:=false;
  65. edit1.text:='';
  66. edit2.text:='';
  67. edit1.SetFocus;
  68. end;
  69.  
  70. procedure Tsrform.SpeedButton2Click(Sender: TObject);
  71. begin
  72. close;
  73. end;
  74.  
  75. procedure Tsrform.SpeedButton1Click(Sender: TObject);
  76. begin
  77. // check the entered numbers
  78. if length(edit1.text) <> length(edit2.text) then
  79.   begin
  80.   mb('The Number of Search Bytes must be equal to the number of Replace Bytes !',':(',mb_iconerror);
  81.   exit;
  82.   end;
  83. if not ishexnum(edit1.text) then
  84.   begin
  85.   mb('The Search Bytes are an invalid hex number !',':(',mb_iconerror);
  86.   exit;
  87.   end;
  88. if not ishexnum(edit2.text) then
  89.   begin
  90.   mb('The Replace Bytes are an invalid hex number !',':(',mb_iconerror);
  91.   exit;
  92.   end;
  93. checknum:=length(edit1.text)/2;
  94. if frac(checknum) <> 0 then
  95.   begin
  96.   mb('The digits of the Search Bytes must be an EVEN number !','!!!',mb_iconerror);
  97.   exit;
  98.   end;
  99. checknum:=length(edit2.text)/2;
  100. if frac(checknum) <> 0 then
  101.   begin
  102.   mb('The digits of the Replace Bytes must be an EVEN number !','!!!',mb_iconerror);
  103.   exit;
  104.   end;
  105. // update the listview
  106. if editing then
  107.   begin  // don't create a new item
  108.   if checkbox1.checked then
  109.    form1.listview1.items[currsel].Caption:='Search & Replace (A)'
  110.   else
  111.    form1.listview1.items[currsel].caption:='Search & Replace (F)';
  112.   form1.listview1.items[currsel].subitems[1]:=edit1.text;
  113.   form1.listview1.items[currsel].subitems[2]:=edit2.text;
  114.   editing:=false;
  115.   end
  116.   else
  117.   begin
  118.   // create a new item
  119.   if radiobutton1.checked then
  120.     newitem:=form1.listview1.Items.Insert(currsel);
  121.   if radiobutton2.checked then
  122.     newitem:=form1.listview1.items.insert(currsel+1);
  123.   if radiobutton3.checked then
  124.     newitem:=form1.listview1.items.add;
  125.   if checkbox1.checked then
  126.    newitem.caption:='Search & Replace (A)'
  127.   else
  128.    newitem.caption:='Search & Replace (F)';
  129.   newitem.subitems.add('');
  130.   newitem.subitems.add(edit1.text);
  131.   newitem.subitems.add(edit2.text);
  132.   end;
  133. close;
  134. end;
  135.  
  136. end.
  137.