home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Power Pack / Visual_Basic4_Power_Pack.bin / vb4files / ilib_vb / imview.cp_ / imview.cp
Encoding:
Text File  |  1996-11-20  |  3.6 KB  |  143 lines

  1. // imview.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "imview.h"
  6.  
  7. #include "mainfrm.h"
  8. #include "mfcdoc.h"
  9. #include "mfcview.h"
  10.  
  11. #ifdef _DEBUG
  12. #undef THIS_FILE
  13. static char BASED_CODE THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CImViewApp
  18.  
  19. BEGIN_MESSAGE_MAP(CImViewApp, CWinApp)
  20.     //{{AFX_MSG_MAP(CImViewApp)
  21.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  22.     //}}AFX_MSG_MAP
  23.     // Standard file based document commands
  24.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  25.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  26. END_MESSAGE_MAP()
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CImViewApp construction
  30. // Place all significant initialization in InitInstance
  31.  
  32. CImViewApp::CImViewApp()
  33. {
  34. }
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // The one and only CImViewApp object
  38.  
  39. CImViewApp NEAR theApp;
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CImViewApp initialization
  43.  
  44. BOOL CImViewApp::InitInstance()
  45. {
  46.     // Standard initialization
  47.     //  (if you are not using these features and wish to reduce the size
  48.     // of your final executable, you should remove the following initialization
  49.  
  50.     SetDialogBkColor();        // set dialog background color
  51.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  52.  
  53.     // Register document templates which serve as connection between
  54.     //  documents and views.  Views are contained in the specified view
  55.  
  56.     AddDocTemplate(new CMultiDocTemplate(IDR_DIBTYPE,
  57.             RUNTIME_CLASS(CMfcDoc),
  58.             RUNTIME_CLASS(CMDIChildWnd),        // standard MDI child frame
  59.             RUNTIME_CLASS(CMfcView)));
  60.  
  61.     // create main MDI Frame window
  62.     CMainFrame* pMainFrame = new CMainFrame;
  63.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  64.         return FALSE;
  65.     pMainFrame->ShowWindow(m_nCmdShow);
  66.     pMainFrame->UpdateWindow();
  67.     m_pMainWnd = pMainFrame;
  68.  
  69.     // enable file manager drag/drop and DDE Execute open
  70.     m_pMainWnd->DragAcceptFiles();
  71.     EnableShellOpen();
  72.     RegisterShellFileTypes();
  73.  
  74.     // simple command line parsing
  75.     if (m_lpCmdLine[0] == '\0')
  76.     {
  77.         // create a new (empty) document
  78.         // OnFileNew();
  79.     }
  80.     else if ((m_lpCmdLine[0] == '-' || m_lpCmdLine[0] == '/') &&
  81.         (m_lpCmdLine[1] == 'e' || m_lpCmdLine[1] == 'E'))
  82.     {
  83.         // program launched embedded - wait for DDE or OLE open
  84.     }
  85.     else
  86.     {
  87.         // open an existing document
  88.         OpenDocumentFile(m_lpCmdLine);
  89.     }
  90.  
  91.  
  92.     return TRUE;
  93. }
  94.  
  95. /////////////////////////////////////////////////////////////////////////////
  96. // CAboutDlg dialog used for App About
  97.  
  98. class CAboutDlg : public CDialog
  99. {
  100. public:
  101.     CAboutDlg() : CDialog(CAboutDlg::IDD)
  102.         {
  103.             //{{AFX_DATA_INIT(CAboutDlg)
  104.             //}}AFX_DATA_INIT
  105.         }
  106.  
  107. // Dialog Data
  108.     //{{AFX_DATA(CAboutDlg)
  109.         enum { IDD = IDD_ABOUTBOX };
  110.     //}}AFX_DATA
  111.  
  112. // Implementation
  113. protected:
  114.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  115.     //{{AFX_MSG(CAboutDlg)
  116.         // No message handlers
  117.     //}}AFX_MSG
  118.     DECLARE_MESSAGE_MAP()
  119. };
  120.  
  121. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  122. {
  123.     CDialog::DoDataExchange(pDX);
  124.     //{{AFX_DATA_MAP(CAboutDlg)
  125.     //}}AFX_DATA_MAP
  126. }
  127.  
  128. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  129.     //{{AFX_MSG_MAP(CAboutDlg)
  130.         // No message handlers
  131.     //}}AFX_MSG_MAP
  132. END_MESSAGE_MAP()
  133.  
  134. // App command to run the dialog
  135. void CImViewApp::OnAppAbout()
  136. {
  137.     CAboutDlg aboutDlg;
  138.     aboutDlg.DoModal();
  139. }
  140.  
  141. /////////////////////////////////////////////////////////////////////////////
  142. // CImViewApp commands
  143.