home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 1995 May / pcw-0595.bin / demos / databeck / wsounds / setup.dir / wswsrc.exe / ABOUTDLG.PAS next >
Pascal/Delphi Source File  |  1992-12-02  |  2KB  |  84 lines

  1. {
  2.        Unit AboutDlg - displays "About..." dialog box
  3. }
  4.  
  5. Unit aboutDlg;
  6.  
  7. INTERFACE
  8. uses WinTypes, WinProcs, WinDos, WObjects, Strings, MMSystem;
  9. {$R aboutres.res}
  10. const
  11.   dn_AboutDlg = 'ABOUTDLG';
  12.  
  13.   id_PlayAbout= 380;
  14.  
  15. type
  16.   PAboutDlg = ^TAboutDlg;
  17.   TAboutDlg = object(TDialog)
  18.     constructor Init(AParent: PWindowsObject;AName: PChar);
  19.     Procedure SetupWindow;virtual;
  20.     Procedure HandleAboutFan(Var Msg : TMessage);virtual id_First + id_PlayAbout;
  21.   private
  22.     Procedure PlayResWave(ResName : PChar);
  23.   end;
  24.  
  25. implementation
  26.  
  27. PROCEDURE TAboutDlg.PlayResWave(ResName : PChar);
  28. {
  29.  * This proc uses SndPlaySound for playing WAV files (SndPlaySound can be
  30.  * found in a resource) using the SND_MEMORY parameter. You can create a
  31.  * WAV resource using a resource script file and the resource compiler RC.EXE.
  32. }
  33.  
  34. VAR
  35.    WavResPtr  : POINTER;
  36.    WavHandle,
  37.    WavResInfo : THandle;
  38. BEGIN
  39.    WavResInfo := FindResource(HInstance,ResName,'WAVE');
  40.    IF NOT(WavResInfo>0) THEN
  41.       Halt(1); { Error: Resource not found }
  42.    WavHandle := LoadResource(Hinstance,WavResInfo);
  43.    IF NOT(WavHandle>0) THEN
  44.       Halt(2);  { Error: No handle found }
  45.    WavResPtr := LockResource(WavHandle);
  46.    IF (WavResPtr <> NIL) THEN BEGIN
  47.       SndPlaySound (WavResPtr,SND_SYNC OR SND_MEMORY);
  48. {
  49.  * The following function call unlocks the resource previously locked into
  50.  * memory using LockResource.
  51.  * Please note: You can only use this function if you're playing a sound
  52.  * using SND_SYNC. Otherwise, a general protection error occurs and the sound
  53.  * will lock up because you accessed a resource not specifically addressable
  54.  * in memory.
  55. }
  56.  
  57.       UnlockResource(WavHandle)
  58.       END;
  59.    END;
  60.  
  61. constructor TAboutDlg.Init(AParent: PWindowsObject;AName: PChar);
  62. begin
  63.   TDialog.Init(AParent, AName);
  64. end;
  65.  
  66. Procedure TAboutDlg.SetupWindow;
  67. VAR
  68.    Msg : TMessage;
  69. BEGIN
  70.    TDialog.SetupWindow;
  71.    TWindowsObject.Show(sw_Show);
  72.    HandleAboutFan(Msg);
  73. {   PostMessage(HWindow, wm_Command, id_PlayAbout,0);}
  74.    END;
  75.  
  76. Procedure TAboutDlg.HandleAboutFan(VAR Msg : TMessage);
  77. BEGIN
  78.    UpdateWindow(HWindow);
  79.    PlayResWave('FANFARE');   { Plays FANFARE.WAV file }
  80.    END;
  81.    
  82. BEGIN
  83.    END.
  84.