| You are here: | About>Computing & Technology>Delphi Programming> Coding Delphi Applications> How to Add an Easter Egg to your Delphi application |
![]() | Delphi Programming |
Add an Easter Egg to your Delphi applicationIn techmythology, Easter Eggs aren't brightly colored protochickens. Easter eggs have always been the opportunity for developers to demonstrate pride in the products that they have been developing for months or even years. Typically, Easter eggs are used to display the credits for the development team (to let the users of their software find out who they are) or to display a humorous message. To see an easter egg, the user needs to know a special procedure or sequence of keystrokes; click in the proper place or edit the right file. In other words they're implemented as undocumented bits of code that come hidden inside operating systems, applications, Web browsers, games, and other programs. Easter Eggs in the Delphi IDEEach version of the Delphi IDE holds a hidden message that highlights the development staff that produced that version of the compiler. In most cases, they are credit lists for the developers of the product, but sometimes they are not.To find what kind of eggs can be hunted down in Delphi, check out Borland Easter Eggs. Implementing an Easter EggOne of the practical uses of Easter eggs that I'm aware of is using Easter eggs as an entry point to special configuration options that the developer doesn't want users to mess around with. Of course this is not the kind of Easter egg we are interested in right now. Coding an Easter egg like that one would be no fun at all.We'll make an Easter egg that displays a hidden (fun) message when the user presses a certain key combination. The same code can be used to, for example, show a simple scrolling text, start a full-blown multimedia presentation or even start a small game users can play. To add an Easter egg to your code do the following:
The hidden word that activates the Egg is held in the sEgg constant and is ADPRULEZ. The icnt integer variable is used to count keystrokes when "hunting" for egg. In the OnCreate event handler the KeyPreview property for the form is set to True. This assures that the Form receives keyboard events before the active control. The main code is in the OnKeyPress even handler. We first check whether the Ctrl key is down. If so, we check if the last keystroke in the sequence was the proper key. If the 'hidden' combination is typed the message box simply displays: 'About Delphi Programming Easter Egg!' Note: those cheat codes like IDKFA you use when playing DOOM clones are just simple Easter eggs. The Secret Spot EggIf you don't want to mess around with typing secret codes, you might think of placing some hidden hot-spot area somewhere on a form. Suppose you have a Splash Screen and a small secret place on a form that calls some code when clicked. The code would go in the Form's OnMouseDown event handler. Note that there should be no visible components placed over the secret spot!procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer) ;Easter eggs are just fluff, but people love them. Add some Easter eggs to your Delphi application and let the users hunt them... |
Las Vegas on a BudgetFind a BargainHotel DealsCheap EatsFree AttractionsEntertainment for Less |
All Topics | Email Article | | | ![]() |
| Advertising Info | News & Events | Work at About | SiteMap | Reprints | Help | Our Story | Be a Guide |
| User Agreement | Ethics Policy | Patent Info. | Privacy Policy | ©2008 About, Inc., A part of The New York Times Company. All rights reserved. |


