home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / ole / mfccalc / mfccalc.cpp < prev    next >
C/C++ Source or Header  |  1998-03-26  |  3KB  |  98 lines

  1. // mfccalc.cpp : Defines the class behaviors for the application.
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "mfccalc.h"
  15. #include "calcdlg.h"
  16.  
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char BASED_CODE THIS_FILE[] = __FILE__;
  20. #endif
  21.  
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CCalcApp
  24.  
  25. BEGIN_MESSAGE_MAP(CCalcApp, CWinApp)
  26.     //{{AFX_MSG_MAP(CCalcApp)
  27.         // NOTE - the ClassWizard will add and remove mapping macros here.
  28.         //    DO NOT EDIT what you see in these blocks of generated code!
  29.     //}}AFX_MSG
  30.     ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  31. END_MESSAGE_MAP()
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CCalcApp construction
  35.  
  36. CCalcApp::CCalcApp()
  37. {
  38.     // TODO: add construction code here,
  39.     // Place all significant initialization in InitInstance
  40. }
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // The one and only CCalcApp object
  44.  
  45. CCalcApp theApp;
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CCalcApp initialization
  49.  
  50. BOOL CCalcApp::InitInstance()
  51. {
  52.     // Standard initialization
  53.     // If you are not using these features and wish to reduce the size
  54.     //  of your final executable, you should remove from the following
  55.     //  the specific initialization routines you do not need.
  56.  
  57.     Enable3dControls();
  58.  
  59.     // Initialize OLE 2.0 libraries
  60.     if (!AfxOleInit())
  61.     {
  62.         AfxMessageBox(IDP_OLE_INIT_FAILED);
  63.         return FALSE;
  64.     }
  65.  
  66.     // Parse the command line to see if launched as OLE server
  67.     if (RunEmbedded() || RunAutomated())
  68.     {
  69.         // Register all OLE server (factories) as running.  This enables the
  70.         //  OLE 2.0 libraries to create objects from other applications.
  71.         COleTemplateServer::RegisterAll();
  72.  
  73.         // Do not continue with rest of initialization.  Wait for
  74.         // client to create a CCalcDlg object instead.
  75.         return TRUE;
  76.     }
  77.  
  78.     // When a server application is launched stand-alone, it is a good idea
  79.     //  to update the system registry in case it has been damaged.
  80.     COleObjectFactory::UpdateRegistryAll();
  81.  
  82.     // create a modeless dialog as the main window of the application
  83.     CCalcDlg* pDlg = new CCalcDlg;
  84.     pDlg->SetVisible(TRUE);
  85.     if (!pDlg->GetVisible())
  86.     {
  87.         AfxMessageBox(IDP_UNABLE_TO_SHOW_CALC);
  88.         return FALSE;
  89.     }
  90.     pDlg->RegisterActive();
  91.  
  92.     // We are using a modeless dialog so we can translate accelerator keys
  93.     // against the dialog.  In order to run the main message pump,
  94.     // InitInstance must return TRUE even though this application is
  95.     // a dialog-based application.
  96.     return TRUE;
  97. }
  98.