//=========================================================================== // IMAGES AND SOUNDS //=========================================================================== // Note: Bitmap (.bmp) images can be made transparent, in which case // whatever color is in the lower left corner will be the transparent // color. The color must be an EXACT match!!! // Images may also be moved in front of or behind other images. //=========================================================================== #include #pragma hdrstop #include "Unit1.h" #include // You must include the multimedia routines #include // You may wish to include the string routines //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { DoubleBuffered = true; // Eliminates some of the flicker } //--------------------------------------------------------------------------- //================================================================= VARIABLES // Only use the string options if the file path is too long to fit on // one line... // String filePathToWindows; // String filePathToOffice; //================================================================= FUNCTIONS // We don't have any in this sampler application. // However, in a larger and more complex application we would probably // want to move much of the code from the event handlers to functions. //============================================================ EVENT HANDLERS //----------------------------------------------------------------- Cat Image void __fastcall TForm1::ImageCatMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { PlaySound( "C:\\Program Files\\Microsoft Office\\media\\CntCD1\\Sounds\\catmew07.wav" , "", SND_ASYNC); //If the path won't fit on one line, you may want to assemble it: //filePathToOffice = // "C:\\Program Files\\Microsoft Office\\media\\CntCD1\\Sounds\\"; //filePathToOffice += "catmew07.wav"; //PlaySound(filePathToOffice.c_str(), "", SND_ASYNC); } //-------------------------------------------------------------- Rocket Image void __fastcall TForm1::ImageRocketMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { PlaySound( "C:\\Program Files\\Microsoft Office\\media\\CntCD1\\Sounds\\spship04.wav" , "", SND_ASYNC); // Make the rocket fly... for (int i = 0; i < 130; i++) { ImageRocket->Left = ImageRocket->Left - 1; Sleep(10); Application->ProcessMessages(); } Sleep(3000); // Return the rocket... ImageRocket->Left = 153; ImageRocket->Top = 16; } //-------------------------------------------------------------- Parrot Image void __fastcall TForm1::ImageParrotMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { PlaySound( "C:\\Program Files\\Microsoft Office\\media\\CntCD1\\Sounds\\parrot0B.wav" , "", SND_ASYNC); } //----------------------------------------------------------- Fireworks Image void __fastcall TForm1::ImageFireworksMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { PlaySound( "C:\\Program Files\\Microsoft Office\\media\\CntCD1\\Sounds\\frwrks0D.wav" , "", SND_ASYNC); } //-------------------------------------------------------------- Scream Image void __fastcall TForm1::ImageScreamMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { PlaySound( "C:\\Program Files\\Microsoft Office\\media\\CntCD1\\Sounds\\scremm0b.wav" , "", SND_ASYNC); } //----------------------------------------------------------------- Dog Image void __fastcall TForm1::ImageDogMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { PlaySound( "C:\\Program Files\\Microsoft Office\\media\\CntCD1\\Sounds\\PNTDOG08.wav" , "", SND_ASYNC); } //------------------------------------------------------------ Startup Button void __fastcall TForm1::ButtonStartupClick(TObject *Sender) { PlaySound( "C:\\WINDOWS\\Media\\Windows XP Startup.wav" , "", SND_ASYNC); } //--------------------------------------------------------- White Phone Image void __fastcall TForm1::ImageWhitePhoneMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { PlaySound("C:\\WINDOWS\\Media\\ringin.wav", "", SND_ASYNC); // Shake the phone around... for (int i = 0; i < 15; i++) { Sleep(20); ImageWhitePhone->Left = ImageWhitePhone->Left - 5; Application->ProcessMessages(); Sleep(20); ImageWhitePhone->Left = ImageWhitePhone->Left + 5; Application->ProcessMessages(); } } //--------------------------------------------------------- Black Phone Image void __fastcall TForm1::ImageBlackPhoneMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { PlaySound("C:\\WINDOWS\\Media\\ringout.wav", "", SND_ASYNC); // Shake the phone around... for (int i = 0; i < 7; i++) { Sleep(20); ImageBlackPhone->Top = ImageBlackPhone->Top - 5; Application->ProcessMessages(); Sleep(20); ImageBlackPhone->Top = ImageBlackPhone->Top + 5; Application->ProcessMessages(); Sleep(20); ImageBlackPhone->Left = ImageBlackPhone->Left - 3; Application->ProcessMessages(); Sleep(20); ImageBlackPhone->Left = ImageBlackPhone->Left + 3; Application->ProcessMessages(); } } //----------------------------------------------------------- Shutdown Button void __fastcall TForm1::ButtonShutdownClick(TObject *Sender) { PlaySound("C:\\WINDOWS\\Media\\Windows XP Shutdown.wav", "", SND_ASYNC); } //---------------------------------------------------------------- That's All