Einzelnen Beitrag anzeigen

Benutzerbild von Deltachaos
Deltachaos

Registriert seit: 20. Feb 2008
Ort: Berlin
195 Beiträge
 
Delphi 7 Personal
 
#1

MessageDlg wird dopellt angezeigt - Solle er aber nicht

  Alt 27. Feb 2008, 18:00
Hllo ich habe mir ein programm geschrieben da texte codiert und decodiret.

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, Printers;

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    Memo1: TMemo;
    GroupBox2: TGroupBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    Label4: TLabel;
    Label5: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    PrintDialog1: TPrintDialog;
    ProgressBar1: TProgressBar;
    ProgressBar2: TProgressBar;
    Label6: TLabel;
    Label7: TLabel;
    Button5: TButton;
    Button6: TButton;
    Label8: TLabel;
    GroupBox3: TGroupBox;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

const
imax : integer = 30;
iwait : integer = 500; //0.5 sec = 500ms

var
key1, key1a, key1b, key2, key2a, key2b, key3, key3a, key3b: string;

procedure _var_;
begin
 key1:= form1.edit1.text;
 key2:= form1.edit2.text;
 key3:= form1.edit3.text;
 key1a := Copy(key1,1,2);
 key1b := Copy(key1,3,4);
 key2a := Copy(key2,1,2);
 key2b := Copy(key2,3,4);
 key3a := Copy(key3,1,2);
 key3b := Copy(key3,3,4);
end;

procedure l;
begin
  form1.ProgressBar1.Position:=form1.ProgressBar1.Position+1;
end;

procedure l1;
begin
  form1.ProgressBar2.Position:=form1.ProgressBar2.Position+30;
end;

procedure l2;
begin
  form1.ProgressBar2.Position:=form1.ProgressBar2.Position+15;
end;

procedure l3;
begin
  form1.ProgressBar2.Position:=form1.ProgressBar2.Position+10;
end;

procedure code;
begin
  form1.ProgressBar1.Max:=imax;
  form1.ProgressBar1.Position:=0;
  form1.ProgressBar2.Max:=imax;
  form1.ProgressBar2.Position:=0;
      begin
        form1.Memo1.text := stringreplace(form1.Memo1.text, '=', '[_0_]' , [rfReplaceAll]);
        form1.Memo1.text := stringreplace(form1.Memo1.text, ':', '[_-_]' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'a','th%6' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'A','th&%6' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'b','g' + key3b + 'fhu' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'B','gf' + key2a + '#hu' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'c','"' + key1a + 'bJs' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'C','"b' + key2a +'%Js' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'd','/' + key2b +'§jT' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'D','' + key3a + '?jT' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'e','&ast' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'E','&a{st' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'f','g@4[' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'F','g' + key2b + '@%4[' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'g','JHG³' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'G','JH²³' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'h','&' + key3b +'%gd' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'H','&' + key1b + '%%gd' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'i','ß}' + key1a + '=47' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'I','ß' + key3a + '}=G47' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'j','&"' + key3a + '31' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'J','&"}31' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'k','&' + key1b + '%$2' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'K','&%' + key3a + ')$2' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'l','9v' + key1b + '45' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'L','9v' + key2a + '[45' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'm','oed' + key3b + '2' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'M','oe' + key1b + 'dß2' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'n','%' + key2a + '-93' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'N','%-;' + key1a + '93' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'o','jdS' + key2a +'t' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'O','jd' + key1b + '§St' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'p','%h'+ key2a +'te' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'P','%ht' + key2b + '!e' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'q','g' + key1a + 'h92' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'Q','g' + key3a + 'h³92' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'r','th' + key3b + 'vg' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'R','th?' + key3b + 'vg' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 's','}\' + key2a + '23' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'S','}\d' + key1b + '³23' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 't','x' + key2b + 'J%"' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'T','xJ' + key1a + '$%"' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'u','²[' + key3b + 'g]{' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'U','²[g' + key2a + '&]{' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'v','ueb' + key3a + 'A' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'V','' + key2a + 'ebA' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'w','%&5' + key3a + '&' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'W','%&' + key1b + '=5&' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'x','g' + key2b + 'htz' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'X','gh{' + key1b + 'tz' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, 'y','(th' + key3a + '{G' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'Y','(th!{' + key1a + 'G' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'z','³E' + key2b + '€w' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, 'Z','³E€@' + key1a + 'w' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, ' ','[H$%³t]' , [rfReplaceAll]);
        form1.memo1.text := StringReplace(form1.memo1.text, '1','' + key1b + '!' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, '2','' + key1b + '"' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, '3','' + key1b + '§' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, '4','' + key1b + '$' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, '5','' + key1b + '%' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, '6','' + key1b + '&' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, '7','' + key1b + '/' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, '8','' + key1b + '(' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, '9','' + key1b + ')' , [rfReplaceAll]);
        l;
        form1.memo1.text := StringReplace(form1.memo1.text, '0','' + key1b + '=' , [rfReplaceAll]);
        l;
        form1.ProgressBar1.Position:=form1.ProgressBar1.Position+1;
        l;
        form1.ProgressBar1.Position:=0;
      end;
end;

procedure decode;
begin
  form1.ProgressBar1.Max:=imax;
  form1.ProgressBar1.Position:=0;
  form1.ProgressBar2.Max:=imax;
  form1.ProgressBar2.Position:=0;
    begin
      form1.memo1.text := StringReplace(form1.memo1.text, '' + key1b + '=','0' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '' + key1b + ')','9' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '' + key1b + '(','8' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '' + key1b + '/','7' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '' + key1b + '&','6' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '' + key1b + '%','5' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '' + key1b + '$','4' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '' + key1b + '§','3' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '' + key1b + '"','2' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '' + key1b + '!','1' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '[H$%³t]',' ' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '³E€@' + key1a + 'w','Z' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '³E' + key2b + '€w','z' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '(th!{' + key1a + 'G','Y' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '(th' + key3a + '{G','y' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, 'gh{' + key1b + 'tz','X' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, 'g' + key2b + 'htz','x' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '%&' + key1b + '=5&','W' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '%&5' + key3a + '&','w' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '' + key2a + 'ebA','V' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, 'ueb' + key3a + 'A','v' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '²[g' + key2a + '&]{','U' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '²[' + key3b + 'g]{','u' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, 'xJ' + key1a + '$%"','T' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, 'x' + key2b + 'J%"','t' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '}\d' + key1b + '³23','S' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '}\' + key2a + '23','s' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, 'th?' + key3b + 'vg','R' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, 'th' + key3b + 'vg','r' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, 'g' + key3a + 'h³92','Q' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, 'g' + key1a + 'h92','q' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '%ht' + key2b + '!e','P' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '%h' + key2a + 'te','p' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, 'jd' + key1b + '§St','O' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, 'jdS' + key2a +'t','o' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '%-;' + key1a + '93','N' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '%' + key2a + '-93','n' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, 'oe' + key1b + 'dß2','M' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, 'oed' + key3b + '2','m' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '9v' + key2a + '[45','L' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '9v' + key1b + '45','l' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '&%' + key3a + ')$2','K' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '&' + key1b + '%$2','k' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '&"}31','J' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '&"' + key3a + '31','j' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, 'ß' + key3a + '}=G47','I' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, 'ß}' + key1a + '=47','i' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, '&' + key1b + '%%gd','H' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '&' + key3b +'%gd','h' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, 'JH²³','G' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, 'JHG³','g' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, 'g' + key2b + '@%4[','F' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, 'g@4[','f' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '&a{st','E' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '&ast','e' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '' + key3a + '?jT','D' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '/' + key2b +'§jT','d' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '"b' + key2a +'%Js','C' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, '"' + key1a + 'bJs','c' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, 'gf' + key2a + '#hu','B' , [rfReplaceAll]);
      l;
      form1.memo1.text := StringReplace(form1.memo1.text, 'g' + key3b + 'fhu','b' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, 'th&%6','A' , [rfReplaceAll]);
      form1.memo1.text := StringReplace(form1.memo1.text, 'th%6','a' , [rfReplaceAll]);
      form1.Memo1.text := stringreplace(form1.Memo1.text, '[_-_]',':' , [rfReplaceAll]);
      form1.Memo1.text := stringreplace(form1.Memo1.text, '[_0_]','=' , [rfReplaceAll]);
      form1.ProgressBar1.Position:=0;
    end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
     TRY
        Memo1.Lines.Loadfromfile(OpenDialog1.Filename);
     EXCEPT
       MessageDlg('Es ist ein Fehler beim Laden der Datei aufgetreten!',
       mtError, [mbOk], 0)
     END;
end;



procedure TForm1.Button2Click(Sender: TObject);
begin
  if SaveDialog1.Execute then
     TRY
        Memo1.Lines.SavetoFile(SaveDialog1.Filename);
     EXCEPT
       MessageDlg('Es ist ein Fehler beim speichern der Datei aufgetreten!',
       mtError, [mbOk], 0)
     END;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  _var_;
  begin
    if form1.RadioButton1.Checked then
      code;
      l1;
    MessageDlg('Codieren erfolgreich beendet',
    mtinformation, [mbOk], 0);
    form1.ProgressBar2.Position:=0;
  end;
  begin
    if form1.RadioButton2.Checked then
      begin;
        code;
        l2;
        code; //ich weis das es zählschleifen gibt! :-)
        l2;
        MessageDlg('Codieren erfolgreich beendet',
        mtinformation, [mbOk], 0);
        form1.ProgressBar2.Position:=0;
      end;
  end;
  begin
    if form1.radiobutton3.checked then
      begin
        code;
        l3;
        code;
        l3;
        code;
        l3;
        MessageDlg('Codieren erfolgreich beendet',
        mtinformation, [mbOk], 0);
        form1.ProgressBar2.Position:=0;
      end;
  end;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  _var_;
  begin
    if form1.RadioButton1.Checked then
      begin
        decode;
        l1;
        MessageDlg('Decodieren erfolgreich beendet',
        mtinformation, [mbOk], 0);
        form1.ProgressBar2.Position:=0;
      end;
  end;
  begin
    if form1.RadioButton2.Checked then
      begin;
        decode;
        l2;
        decode; //ich weis das es zählschleifen gibt! :-)
        l2;
        MessageDlg('Decodieren erfolgreich beendet',
        mtinformation, [mbOk], 0);
        form1.ProgressBar2.Position:=0;
      end;
  end;

  begin;
    if form1.radiobutton3.checked then
      begin
        decode;
        l3;
        decode;
        l3;
        decode;
        l3;
        MessageDlg('Decodieren erfolgreich beendet',
        mtinformation, [mbOk], 0);
        form1.ProgressBar2.Position:=0;
      end;
  end;
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
  memo1.Lines.Clear
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
  with Printer do
  begin
    BeginDoc;
    Canvas.TextRect(Rect(200,200,PageWidth-200,PageHeight-200),
                    200, 200, Memo1.Lines.Text);
    EndDoc;
  end;
  MessageDlg('Druckauftrag wurde gesendet!',
  mtinformation, [mbOk], 0);
end;

end.
doch komischer weise becomme ich bei der gewehlen radio button2 und 3 die ervolgsmeldung immer 2 mal. ich konnte aber keien fehler entdeckenF
Maximilian Ruta
  Mit Zitat antworten Zitat