home *** CD-ROM | disk | FTP | other *** search
/ Media Share 13 / mediashare_13.zip / mediashare_13 / ZIPPED / PROGRAM / WTJ9403.ZIP / OTEXT / OTEXT.CPP < prev    next >
C/C++ Source or Header  |  1994-01-01  |  5KB  |  182 lines

  1. // otext.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "otext.h"
  6.  
  7. #include "mainfrm.h"
  8. #include "ipframe.h"
  9. #include "otextdoc.h"
  10. #include "otextvw.h"
  11.  
  12. #ifdef _DEBUG
  13. #undef THIS_FILE
  14. static char BASED_CODE THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // COTextApp
  19.  
  20. BEGIN_MESSAGE_MAP(COTextApp, CWinApp)
  21.     //{{AFX_MSG_MAP(COTextApp)
  22.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  23.         // NOTE - the ClassWizard will add and remove mapping macros here.
  24.         //    DO NOT EDIT what you see in these blocks of generated code!
  25.     //}}AFX_MSG_MAP
  26.     // Standard file based document commands
  27.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  28.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  29.     // Standard print setup command
  30.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  31. END_MESSAGE_MAP()
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // COTextApp construction
  35.  
  36. COTextApp::COTextApp()
  37. {
  38.     // TODO: add construction code here,
  39.     // Place all significant initialization in InitInstance
  40. }
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // The one and only COTextApp object
  44.  
  45. COTextApp NEAR theApp;
  46.  
  47. // This identifier was generated to be statistically unique for your app.
  48. // You may change it if you prefer to choose a specific identifier.
  49. static const CLSID BASED_CODE clsid =
  50. { 0x1231caa0, 0xe8fd, 0x101a, { 0xbb, 0x63, 0x4, 0x2, 0x1c, 0x0, 0x94, 0x2 } };
  51.  
  52. /////////////////////////////////////////////////////////////////////////////
  53. // COTextApp initialization
  54.  
  55. BOOL COTextApp::InitInstance()
  56. {
  57.     // Initialize OLE 2.0 libraries
  58.     if (!AfxOleInit())
  59.     {
  60.         AfxMessageBox(IDP_OLE_INIT_FAILED);
  61.         return FALSE;
  62.     }
  63.  
  64.     // Standard initialization
  65.     // If you are not using these features and wish to reduce the size
  66.     //  of your final executable, you should remove from the following
  67.     //  the specific initialization routines you do not need.
  68.  
  69.     SetDialogBkColor();        // Set dialog background color to gray
  70.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  71.  
  72.     // Register the application's document templates.  Document templates
  73.     //  serve as the connection between documents, frame windows and views.
  74.  
  75.     CSingleDocTemplate* pDocTemplate;
  76.     pDocTemplate = new CSingleDocTemplate(
  77.         IDR_MAINFRAME,
  78.         RUNTIME_CLASS(COTextDoc),
  79.         RUNTIME_CLASS(CMainFrame),     // main SDI frame window
  80.         RUNTIME_CLASS(COTextView));
  81.     pDocTemplate->SetServerInfo(
  82.         IDR_SRVR_EMBEDDED, IDR_SRVR_INPLACE,
  83.         RUNTIME_CLASS(CInPlaceFrame));
  84.     AddDocTemplate(pDocTemplate);
  85.  
  86.     // Connect the COleTemplateServer to the document template.
  87.     //  The COleTemplateServer creates new documents on behalf
  88.     //  of requesting OLE containers by using information
  89.     //  specified in the document template.
  90.     m_server.ConnectTemplate(clsid, pDocTemplate, TRUE);
  91.         // Note: SDI applications register server objects only if /Embedding
  92.         //   or /Automation is present on the command line.
  93.  
  94.     // enable file manager drag/drop and DDE Execute open
  95.     EnableShellOpen();
  96.     RegisterShellFileTypes();
  97.  
  98.     // Parse the command line to see if launched as OLE server
  99.     if (RunEmbedded() || RunAutomated())
  100.     {
  101.         // Register all OLE server (factories) as running.  This enables the
  102.         //  OLE 2.0 libraries to create objects from other applications.
  103.         COleTemplateServer::RegisterAll();
  104.  
  105.         // Application was run with /Embedding or /Automation.  Don't show the
  106.         //  main window in this case.
  107.         return TRUE;
  108.     }
  109.  
  110.     // When a server application is launched stand-alone, it is a good idea
  111.     //  to update the system registry in case it has been damaged.
  112.     m_server.UpdateRegistry(OAT_INPLACE_SERVER);
  113.     COleObjectFactory::UpdateRegistryAll();
  114.  
  115.     // simple command line parsing
  116.     if (m_lpCmdLine[0] == '\0')
  117.     {
  118.         // create a new (empty) document
  119.         OnFileNew();
  120.     }
  121.     else
  122.     {
  123.         // open an existing document
  124.         OpenDocumentFile(m_lpCmdLine);
  125.     }
  126.  
  127.     m_pMainWnd->DragAcceptFiles();
  128.  
  129.     return TRUE;
  130. }
  131.  
  132. /////////////////////////////////////////////////////////////////////////////
  133. // CAboutDlg dialog used for App About
  134.  
  135. class CAboutDlg : public CDialog
  136. {
  137. public:
  138.     CAboutDlg();
  139.  
  140. // Dialog Data
  141.     //{{AFX_DATA(CAboutDlg)
  142.     enum { IDD = IDD_ABOUTBOX };
  143.     //}}AFX_DATA
  144.  
  145. // Implementation
  146. protected:
  147.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  148.     //{{AFX_MSG(CAboutDlg)
  149.         // No message handlers
  150.     //}}AFX_MSG
  151.     DECLARE_MESSAGE_MAP()
  152. };
  153.  
  154. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  155. {
  156.     //{{AFX_DATA_INIT(CAboutDlg)
  157.     //}}AFX_DATA_INIT
  158. }
  159.  
  160. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  161. {
  162.     CDialog::DoDataExchange(pDX);
  163.     //{{AFX_DATA_MAP(CAboutDlg)
  164.     //}}AFX_DATA_MAP
  165. }
  166.  
  167. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  168.     //{{AFX_MSG_MAP(CAboutDlg)
  169.         // No message handlers
  170.     //}}AFX_MSG_MAP
  171. END_MESSAGE_MAP()
  172.  
  173. // App command to run the dialog
  174. void COTextApp::OnAppAbout()
  175. {
  176.     CAboutDlg aboutDlg;
  177.     aboutDlg.DoModal();
  178. }
  179.  
  180. /////////////////////////////////////////////////////////////////////////////
  181. // COTextApp commands
  182.