home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch28 / announce / announce.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-11  |  4.4 KB  |  192 lines

  1. // announce.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "announce.h"
  6.  
  7. #include "mainfrm.h"
  8. #include "annoudoc.h"
  9. #include "annouvw.h"
  10.  
  11. #ifdef _DEBUG
  12. #undef THIS_FILE
  13. static char BASED_CODE THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CAnnounceApp
  18.  
  19. BEGIN_MESSAGE_MAP(CAnnounceApp, CWinApp)
  20.     //{{AFX_MSG_MAP(CAnnounceApp)
  21.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  22.         // NOTE - the ClassWizard will add and remove mapping macros here.
  23.         //    DO NOT EDIT what you see in these blocks of generated code!
  24.     //}}AFX_MSG_MAP
  25.     // Standard file based document commands
  26.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  27.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  28. END_MESSAGE_MAP()
  29.  
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CAnnounceApp construction
  32.  
  33. CAnnounceApp::CAnnounceApp()
  34. {
  35.     // TODO: add construction code here,
  36.     // Place all significant initialization in InitInstance
  37.     
  38.   ///////////////////////
  39.   // MY CODE STARTS HERE
  40.   //////////////////////
  41.  
  42.   // Open a sound session with the ITSBEEN1.WAV file.
  43.   m_ItsBeenFunSession =
  44.       sp_OpenSession ("\\VCPROG\\WAV\\ITSBEEN1.WAV");
  45.  
  46.   ////////////////////
  47.   // MY CODE ENDS HERE
  48.   ////////////////////
  49.     
  50. }
  51.  
  52. /////////////////////////////////////////////////////////////////////////////
  53. // The one and only CAnnounceApp object
  54.  
  55. CAnnounceApp NEAR theApp;
  56.  
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CAnnounceApp initialization
  59.  
  60. BOOL CAnnounceApp::InitInstance()
  61. {
  62.     // Standard initialization
  63.     // If you are not using these features and wish to reduce the size
  64.     //  of your final executable, you should remove from the following
  65.     //  the specific initialization routines you do not need.
  66.  
  67.     SetDialogBkColor();        // Set dialog background color to gray
  68.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  69.  
  70.     // Register the application's document templates.  Document templates
  71.     //  serve as the connection between documents, frame windows and views.
  72.  
  73.     CSingleDocTemplate* pDocTemplate;
  74.     pDocTemplate = new CSingleDocTemplate(
  75.         IDR_MAINFRAME,
  76.         RUNTIME_CLASS(CAnnounceDoc),
  77.         RUNTIME_CLASS(CMainFrame),     // main SDI frame window
  78.         RUNTIME_CLASS(CAnnounceView));
  79.     AddDocTemplate(pDocTemplate);
  80.  
  81.     // create a new (empty) document
  82.     OnFileNew();
  83.  
  84.     if (m_lpCmdLine[0] != '\0')
  85.     {
  86.         // TODO: add command line processing here
  87.     }
  88.  
  89.  
  90.     return TRUE;
  91. }
  92.  
  93. /////////////////////////////////////////////////////////////////////////////
  94. // CAboutDlg dialog used for App About
  95.  
  96. class CAboutDlg : public CDialog
  97. {
  98. public:
  99.     CAboutDlg();
  100.  
  101. // Dialog Data
  102.     //{{AFX_DATA(CAboutDlg)
  103.     enum { IDD = IDD_ABOUTBOX };
  104.     //}}AFX_DATA
  105.  
  106. // Implementation
  107. protected:
  108.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  109.     //{{AFX_MSG(CAboutDlg)
  110.         // No message handlers
  111.     //}}AFX_MSG
  112.     DECLARE_MESSAGE_MAP()
  113. };
  114.  
  115. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  116. {
  117.     //{{AFX_DATA_INIT(CAboutDlg)
  118.     //}}AFX_DATA_INIT
  119. }
  120.  
  121. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  122. {
  123.     CDialog::DoDataExchange(pDX);
  124.     //{{AFX_DATA_MAP(CAboutDlg)
  125.     //}}AFX_DATA_MAP
  126. }
  127.  
  128. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  129.     //{{AFX_MSG_MAP(CAboutDlg)
  130.         // No message handlers
  131.     //}}AFX_MSG_MAP
  132. END_MESSAGE_MAP()
  133.  
  134. // App command to run the dialog
  135. void CAnnounceApp::OnAppAbout()
  136. {
  137.     CAboutDlg aboutDlg;
  138.     aboutDlg.DoModal();
  139. }
  140.  
  141. /////////////////////////////////////////////////////////////////////////////
  142. // CAnnounceApp commands
  143.  
  144.  
  145. //////////////////////
  146. // MY CODE STARTS HERE
  147. //////////////////////
  148.  
  149. BOOL CAnnounceApp::OnIdle(LONG lCount)
  150. {
  151.  
  152.    // Call the base class.
  153.    CWinApp::OnIdle(lCount);
  154.  
  155.    // Beep.
  156.    ////MessageBeep(-1);
  157.  
  158.    // Is the Exit Windows window on the desktop?
  159.    HWND hWindow = FindWindow (NULL, "Exit Windows" );
  160.    if (hWindow)
  161.       {
  162.       sp_PlaySnd (m_ItsBeenFunSession,
  163.                   SP_START_OF_FILE,
  164.                   SP_END_OF_FILE);
  165.       }
  166.  
  167.    return TRUE;
  168.  
  169. }
  170.  
  171. ////////////////////
  172. // MY CODE ENDS HERE
  173. ////////////////////
  174.  
  175. ///////////////////////
  176. // MY CODE STARTS HERE
  177. //////////////////////
  178.  
  179. int CAnnounceApp::ExitInstance()
  180. {
  181.  
  182. // Close the sound session.
  183. sp_CloseSession(m_ItsBeenFunSession);
  184.  
  185. return CWinApp::ExitInstance();
  186.  
  187. }
  188.  
  189. ////////////////////
  190. // MY CODE ENDS HERE
  191. ////////////////////
  192.