Fórum Ovo de pascoa #173051

04/08/2003

0

Galera gostaria de saber, como eu posso fazer para colocar em meu prog um codigo secreto. Eu digito uma sequencia de caracteres ai ele faz algo.

Exe: Alt+superdelphi ------> abrirar uma jalena com informações.

Desde já muito obrigado.


Superdelphi

Superdelphi

Responder

Posts

08/08/2003

Cebikyn

Instruções em inglês (se precisar de ajuda na tradução, é só pedir)


To create your own easter egg take this steps:

1.- Start a new Project

2.- Create the following private fields:

...
private
    FEgg: String;
    FCount: Integer;
...

FCount holds a count of KEYSTROKES.
FEgg holds the KEYSTROKES string.

3.- Create two constants

...
const
  EE_CONTROL: TShiftState = [ssCtrl, ssAlt];
  EASTER_EGG = ´SECRET´;
..

EE_CONTROL contains the control keys that must be down when the user types the EASTER_EGG string

4.- In the OnCreate event of the form write

procedure TForm1.FormCreate(Sender: TObject);
begin
  FCount := 1;
  FEgg := EASTER_EGG;
end;

5.- In the OnKeyDown event of the form write

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
//Are the correct control keys down?
  if Shift = EE_CONTROL then 
  begin
    //was the proper key pressed?
    if Key = Ord(FEgg[FCount]) then
    begin
      //was this the last keystroke in the sequence?
      if FCount = Length(FEgg) then 
      begin
        //Code of the easter egg
        ShowMessage(´Add your own code here!´);
        //failure - reset the count
        FCount := 1; {}
      end
      else
      begin
        //success - increment the count
        Inc(FCount);
      end;
    end
    else
    begin
      //failure - reset the count
      FCount := 1;
    end;
  end;
end;

6.- Finally set the Form´s KeyPreview property to true.


Now you just have to replace the ShowMessage with Something more creative, use your imagination!



Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar