home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / MFC / SAMPLES / OCLIENT / OCLIENT.CP_ / OCLIENT.CP
Encoding:
Text File  |  1993-02-08  |  3.3 KB  |  125 lines

  1. // oclient.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 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 Microsoft
  9. // QuickHelp and/or WinHelp documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13.  
  14.  
  15. #include "stdafx.h"
  16. #include "oclient.h"
  17.  
  18. #include "frame.h"
  19. #include "maindoc.h"
  20. #include "mainview.h"
  21.  
  22. #ifdef _DEBUG
  23. #undef THIS_FILE
  24. static char BASED_CODE THIS_FILE[] = __FILE__;
  25. #endif
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // COleClientApp
  29.  
  30. BEGIN_MESSAGE_MAP(COleClientApp, CWinApp)
  31.     //{{AFX_MSG_MAP(COleClientApp)
  32.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  33.     //}}AFX_MSG_MAP
  34.     // Standard file based document commands
  35.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  36.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  37.     // Standard print setup command
  38.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  39. END_MESSAGE_MAP()
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // COleClientApp construction
  43. // Place all significant initialization in InitInstance
  44.  
  45. COleClientApp::COleClientApp()
  46. {
  47. }
  48.  
  49. /////////////////////////////////////////////////////////////////////////////
  50. // The one and only COleClientApp object
  51.  
  52. COleClientApp NEAR theApp;
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // COleClientApp initialization
  56.  
  57. BOOL COleClientApp::InitInstance()
  58. {
  59.     // Standard initialization
  60.  
  61.     SetDialogBkColor();        // set dialog background color
  62.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  63.  
  64.     // Register document templates
  65.  
  66.     AddDocTemplate(new CMultiDocTemplate(IDR_OLECLITYPE,
  67.             RUNTIME_CLASS(CMainDoc),
  68.             RUNTIME_CLASS(CMDIChildWnd),        // standard MDI child frame
  69.             RUNTIME_CLASS(CMainView)));
  70.  
  71.     // create main MDI Frame window
  72.     CMainFrame* pMainFrame = new CMainFrame;
  73.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  74.         return FALSE;
  75.     pMainFrame->ShowWindow(m_nCmdShow);
  76.     pMainFrame->UpdateWindow();
  77.     m_pMainWnd = pMainFrame;
  78.  
  79.     // enable file manager drag/drop and DDE Execute open
  80.     m_pMainWnd->DragAcceptFiles();
  81.     EnableShellOpen();
  82.     RegisterShellFileTypes();
  83.  
  84.     // simple command line parsing
  85.     if (m_lpCmdLine[0] == '\0')
  86.     {
  87.         // create a new (empty) document
  88.         OnFileNew();
  89.     }
  90.     else if ((m_lpCmdLine[0] == '-' || m_lpCmdLine[0] == '/') &&
  91.         (m_lpCmdLine[1] == 'e' || m_lpCmdLine[1] == 'E'))
  92.     {
  93.         // program launched embedded - wait for DDE or OLE open
  94.     }
  95.     else
  96.     {
  97.         // open an existing document
  98.         OpenDocumentFile(m_lpCmdLine);
  99.     }
  100.  
  101.  
  102.     return TRUE;
  103. }
  104.  
  105. /////////////////////////////////////////////////////////////////////////////
  106. // COleClientApp commands
  107.  
  108. void COleClientApp::OnAppAbout()
  109. {
  110.     CDialog(IDD_ABOUTBOX).DoModal();
  111. }
  112.  
  113.  
  114. /////////////////////////////////////////////////////////////////////////////
  115. // utility functions
  116.  
  117. LPSTR CreateNewUniqueName(LPSTR lpstr)
  118. {
  119.     static int CurrentNumber = 0;
  120.     wsprintf(lpstr, "%s%04d", (LPSTR)OBJ_NAME_PREFIX, CurrentNumber++);
  121.     return(lpstr);
  122. }
  123.  
  124. /////////////////////////////////////////////////////////////////////////////
  125.