home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK8 / MFC / SAMPLES / MULTIPAD / MPINIT.CP$ / mpinit
Encoding:
Text File  |  1992-03-14  |  1.7 KB  |  69 lines

  1. // mpinit.cpp : Defines the application initialization.
  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 documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "multipad.h"
  14.  
  15. #pragma code_seg("_MPINIT")
  16.  
  17. // InitInstance:
  18. // Does the typical printer and frame initialization, as well as loading a
  19. // file if one is listed on the command line.  Note that only one filename
  20. // on the command line is currently supported.
  21. //
  22. BOOL CMultiPad::InitInstance()
  23. {
  24.     extern void LoadMRU();
  25.     extern CPrinter* thePrinter;
  26.     char szCmdLine[128];
  27.     char* pCmdLine;
  28.     
  29.     LoadMRU();
  30.     
  31.     // Create the frame.
  32.     //
  33.     m_pMainWnd = new CMPFrame(m_pszAppName);
  34.     if (m_pMainWnd->m_hWnd == NULL)
  35.         return FALSE;
  36.     
  37.     // Create the printer object
  38.     thePrinter = new CPrinter;
  39.  
  40.     // Load main menu accelerators.
  41.     //
  42.     if (!CMPFrame::GetMDIFrameWnd()->LoadAccelTable(MAKEINTRESOURCE(IDMULTIPAD)))
  43.         return FALSE;
  44.  
  45.     // Display the frame window.
  46.     //
  47.     m_pMainWnd->ShowWindow(m_nCmdShow);
  48.     m_pMainWnd->UpdateWindow();
  49.     
  50.     // If the command line string is empty, nullify the pointer to it,
  51.     // otherwise copy command line into our data segment.
  52.     //
  53.     if (m_lpCmdLine == NULL || m_lpCmdLine[0] == '\0')
  54.     {
  55.         pCmdLine = NULL;
  56.     }
  57.     else
  58.     {
  59.         pCmdLine = szCmdLine;
  60.         lstrcpy(pCmdLine, m_lpCmdLine);
  61.     }
  62.     
  63.     // Add the first MDI window.
  64.     //
  65.     new CMPChild(pCmdLine);
  66.  
  67.     return TRUE;
  68. }
  69.