home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / SCRIB7.PAK / SCRIBBLE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  6.2 KB  |  212 lines

  1. // Scribble.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-1995 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 "Scribble.h"
  15.  
  16. #include "MainFrm.h"
  17. #include "ChildFrm.h"
  18. #include "IpFrame.h"
  19. #include "ScribDoc.h"
  20. #include "ScribVw.h"
  21.  
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CScribbleApp
  30.  
  31. BEGIN_MESSAGE_MAP(CScribbleApp, CWinApp)
  32.     //{{AFX_MSG_MAP(CScribbleApp)
  33.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  34.         // NOTE - the ClassWizard will add and remove mapping macros here.
  35.         //    DO NOT EDIT what you see in these blocks of generated code!
  36.     //}}AFX_MSG_MAP
  37.     // Standard file based document commands
  38.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  39.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  40.     // Standard print setup command
  41.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  42. END_MESSAGE_MAP()
  43.  
  44. /////////////////////////////////////////////////////////////////////////////
  45. // CScribbleApp construction
  46.  
  47. CScribbleApp::CScribbleApp()
  48. {
  49.     // TODO: add construction code here,
  50.     // Place all significant initialization in InitInstance
  51. }
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // The one and only CScribbleApp object
  55.  
  56. CScribbleApp theApp;
  57.  
  58. // This identifier was generated to be statistically unique for your app.
  59. // You may change it if you prefer to choose a specific identifier.
  60.  
  61. // {7559FD90-9B93-11CE-B0F0-00AA006C28B3}
  62. static const CLSID clsid =
  63. { 0x7559fd90, 0x9b93, 0x11ce, { 0xb0, 0xf0, 0x0, 0xaa, 0x0, 0x6c, 0x28, 0xb3 } };
  64.  
  65. /////////////////////////////////////////////////////////////////////////////
  66. // CScribbleApp initialization
  67.  
  68. BOOL CScribbleApp::InitInstance()
  69. {
  70.     // Initialize OLE libraries
  71.     if (!AfxOleInit())
  72.     {
  73.         AfxMessageBox(IDP_OLE_INIT_FAILED);
  74.         return FALSE;
  75.     }
  76.  
  77.     // Standard initialization
  78.     // If you are not using these features and wish to reduce the size
  79.     //  of your final executable, you should remove from the following
  80.     //  the specific initialization routines you do not need.
  81.  
  82. #ifdef _AFXDLL
  83.     Enable3dControls();                     // Call this when using MFC in a shared DLL
  84. #else
  85.     Enable3dControlsStatic();       // Call this when linking to MFC statically
  86. #endif
  87.  
  88.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  89.  
  90.     
  91.     // Register the application's document templates.  Document templates
  92.     //  serve as the connection between documents, frame windows and views.
  93.  
  94.     CMultiDocTemplate* pDocTemplate;
  95.     pDocTemplate = new CMultiDocTemplate(
  96.         IDR_SCRIBBTYPE,
  97.         RUNTIME_CLASS(CScribbleDoc),
  98.         RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  99.         RUNTIME_CLASS(CScribbleView));
  100.  
  101.     pDocTemplate->SetServerInfo(
  102.         IDR_SCRIBBTYPE_SRVR_EMB, IDR_SCRIBBTYPE_SRVR_IP,
  103.         RUNTIME_CLASS(CInPlaceFrame));
  104.  
  105.     AddDocTemplate(pDocTemplate);
  106.     // Connect the COleTemplateServer to the document template.
  107.     //  The COleTemplateServer creates new documents on behalf
  108.     //  of requesting OLE containers by using information
  109.     //  specified in the document template.
  110.     m_server.ConnectTemplate(clsid, pDocTemplate, FALSE);
  111.  
  112.     // Register all OLE server factories as running.  This enables the
  113.     //  OLE libraries to create objects from other applications.
  114.     COleTemplateServer::RegisterAll();
  115.         // Note: MDI applications register all server objects without regard
  116.         //  to the /Embedding or /Automation on the command line.
  117.  
  118.  
  119.     // create main MDI Frame window
  120.     CMainFrame* pMainFrame = new CMainFrame;
  121.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  122.         return FALSE;
  123.     m_pMainWnd = pMainFrame;
  124.  
  125.     // Enable drag/drop open.  We don't call this in Win32, since a
  126.     //  document file extension wasn't chosen while running AppWizard.
  127.     m_pMainWnd->DragAcceptFiles();
  128.  
  129.     // Parse command line for standard shell commands, DDE, file open
  130.     CCommandLineInfo cmdInfo;
  131.     ParseCommandLine(cmdInfo);
  132.  
  133.     // Check to see if launched as OLE server
  134.     if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
  135.     {
  136.         // Application was run with /Embedding or /Automation.  Don't show the
  137.         //  main window in this case.
  138.         return TRUE;
  139.     }
  140.  
  141.     // When a server application is launched stand-alone, it is a good idea
  142.     //  to update the system registry in case it has been damaged.
  143.     m_server.UpdateRegistry(OAT_INPLACE_SERVER);
  144.  
  145.     // Dispatch commands specified on the command line
  146.     if (!ProcessShellCommand(cmdInfo))
  147.         return FALSE;
  148.  
  149.     
  150.     // The main window has been initialized, so show and update it.
  151.     pMainFrame->ShowWindow(m_nCmdShow);
  152.     pMainFrame->UpdateWindow();
  153.  
  154.     return TRUE;
  155. }
  156.  
  157. /////////////////////////////////////////////////////////////////////////////
  158. // CAboutDlg dialog used for App About
  159.  
  160. class CAboutDlg : public CDialog
  161. {
  162. public:
  163.     CAboutDlg();
  164.  
  165. // Dialog Data
  166.     //{{AFX_DATA(CAboutDlg)
  167.     enum { IDD = IDD_ABOUTBOX };
  168.     //}}AFX_DATA
  169.     
  170.     // ClassWizard generated virtual function overrides
  171.     //{{AFX_VIRTUAL(CAboutDlg)
  172.     protected:
  173.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  174.     //}}AFX_VIRTUAL
  175.  
  176. // Implementation
  177. protected:
  178.     //{{AFX_MSG(CAboutDlg)
  179.         // No message handlers
  180.     //}}AFX_MSG
  181.     DECLARE_MESSAGE_MAP()
  182. };
  183.  
  184. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  185. {
  186.     //{{AFX_DATA_INIT(CAboutDlg)
  187.     //}}AFX_DATA_INIT
  188. }
  189.  
  190. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  191. {
  192.     CDialog::DoDataExchange(pDX);
  193.     //{{AFX_DATA_MAP(CAboutDlg)
  194.     //}}AFX_DATA_MAP
  195. }
  196.  
  197. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  198.     //{{AFX_MSG_MAP(CAboutDlg)
  199.         // No message handlers
  200.     //}}AFX_MSG_MAP
  201. END_MESSAGE_MAP()
  202.  
  203. // App command to run the dialog
  204. void CScribbleApp::OnAppAbout()
  205. {
  206.     CAboutDlg aboutDlg;
  207.     aboutDlg.DoModal();
  208. }
  209.  
  210. /////////////////////////////////////////////////////////////////////////////
  211. // CScribbleApp commands
  212.