home *** CD-ROM | disk | FTP | other *** search
/ Using Visual Basic 5 (Platinum Edition) / vb5.iso / ACTIVEX / SRDVID / DATA.1 / svviewer.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-10  |  3.5 KB  |  140 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // svviewer.cpp : Defines the class behaviors for the application.
  4. //
  5. /////////////////////////////////////////////////////////////////////////////
  6. //
  7. //  (C) Copyright Black Diamond Consulting, Inc 1996. All rights reserved.
  8. //
  9. //    You have a royalty-free right to use, modify, reproduce and 
  10. //    distribute the Sample Files (and/or any modified version) in 
  11. //    any way you find useful, provided that you agree that Black 
  12. //    Diamond Consulting has no warranty obligations or liability
  13. //    for any Sample Application Files which are modified. 
  14. //
  15. //    Revision History:
  16. //
  17. /////////////////////////////////////////////////////////////////////////////
  18.  
  19. #include "stdafx.h"
  20. #include <initguid.h>
  21. #include "Surround.h"
  22.  
  23. #ifndef __SVVIEWER_H__
  24.     #include "SVViewer.h"
  25. #endif
  26.  
  27. #ifndef __MAINFRM_H__
  28.     #include "mainfrm.h"
  29. #endif
  30.  
  31. #ifndef __SVDOC_H__
  32.     #include "SVDoc.h"
  33. #endif               
  34.  
  35. #ifndef __SVVIEW_H__
  36.     #include "SVView.h"
  37. #endif
  38.  
  39. #ifndef __ABOUTBOX_H__
  40.     #include "AboutBox.h"
  41. #endif
  42.  
  43. #ifdef _DEBUG
  44. #undef THIS_FILE
  45. static char BASED_CODE THIS_FILE[] = __FILE__;
  46. #endif
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CSVViewerApp
  50.  
  51. BEGIN_MESSAGE_MAP(CSVViewerApp, CWinApp)
  52.     //{{AFX_MSG_MAP(CSVViewerApp)
  53.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  54.     //}}AFX_MSG_MAP
  55.     // Standard file based document commands
  56.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  57.     ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  58.     // Standard print setup command
  59. END_MESSAGE_MAP()
  60.  
  61. /////////////////////////////////////////////////////////////////////////////
  62. // The one and only CSVViewerApp object
  63.  
  64. CSVViewerApp theApp;
  65.  
  66. /////////////////////////////////////////////////////////////////////////////
  67. // CSVViewerApp construction
  68.  
  69. CSVViewerApp::CSVViewerApp()
  70. {
  71.     // TODO: add construction code here,
  72.     // Place all significant initialization in InitInstance
  73. }
  74.  
  75. /////////////////////////////////////////////////////////////////////////////
  76. // CSVViewerApp initialization
  77.  
  78. BOOL CSVViewerApp::InitInstance()
  79. {
  80.     // Initialize OLE libraries
  81.     if (!AfxOleInit())
  82.     {
  83.         AfxMessageBox(IDP_OLE_INIT_FAILED);
  84.         return FALSE;
  85.     }
  86.  
  87.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  88.  
  89.     // Register the application's document template.  Document templates
  90.     //  serve as the connection between documents, frame windows and views.
  91.     AddDocTemplate(new CSingleDocTemplate( IDR_MAINFRAME,
  92.                                            RUNTIME_CLASS(CSVViewerDoc),
  93.                                            RUNTIME_CLASS(CMainFrame), 
  94.                                            RUNTIME_CLASS(CSVViewerView)));
  95.  
  96.     // create a new (empty) document
  97.     OnFileNew();
  98.  
  99.     if (m_lpCmdLine[0] != '\0')
  100.     {
  101.         OpenDocumentFile( m_lpCmdLine );
  102.     }
  103.  
  104.     return TRUE;
  105. }
  106.  
  107. /////////////////////////////////////////////////////////////////////////////
  108. // CSVViewerApp commands
  109.  
  110. void CSVViewerApp::OnFileOpen()
  111. {
  112.     CString newName;
  113.  
  114.     // Put up a File dialog to get user's file choice, if he makes one...
  115.     CFileDialog cDlg(    TRUE,
  116.                         NULL,
  117.                         "*.svi;*.bmp;*.dib",
  118.                         OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_FILEMUSTEXIST,
  119.                         "Surround Video Image (*.svi)|*.svi|Bitmap file (*.bmp;*.dib)|*.bmp;*.dib||",
  120.                         NULL );
  121.                         
  122.     cDlg.m_ofn.lpstrTitle = "Open";
  123.  
  124.     if( cDlg.DoModal() != IDOK )
  125.         return;
  126.  
  127.     newName = cDlg.GetPathName();    
  128.  
  129.     OpenDocumentFile(newName);
  130. }
  131.  
  132.  
  133. // App command to run the dialog
  134. void CSVViewerApp::OnAppAbout()
  135. {
  136.     CAboutBox aboutDlg;
  137.     aboutDlg.DoModal();
  138. }
  139.  
  140.