home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / winui / shell / fileview / ifilevw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-12  |  4.0 KB  |  135 lines

  1. //THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
  2. //ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
  3. //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright  1994-1996  Microsoft Corporation.  All Rights Reserved.
  7. //
  8. //    PROGRAM:    IFILEVW.CPP    
  9. //
  10. //    PURPOSE: IFileViewer interface implementation for a FileViewer.
  11. // Custom FileViewer objects should modify the Show member
  12. // to suit its own needs. 
  13. //
  14. //    PLATFORMS:    Windows 95
  15. //
  16. //    SPECIAL INSTRUCTIONS: N/A
  17. //
  18.  
  19. #include "fileview.h"
  20.  
  21. //
  22. //   FUNCTION: CImpIFileViewer::CImpIFileViewer    
  23. //
  24. //   PURPOSE:   Constructor
  25. //
  26. //   PARAMETERS: 
  27. //      pObj            PCFileViewer of the object we're in.
  28. //    pUnkOuter       LPUNKNOWN to which we delegate.
  29. //
  30. CImpIFileViewer::CImpIFileViewer(PCFileViewer pObj
  31.     , LPUNKNOWN pUnkOuter)
  32.     {
  33.     m_pObj=pObj;
  34.     m_pUnkOuter=pUnkOuter;
  35.     return;
  36.     }     
  37. //
  38. //   FUNCTION:     CImpIFileViewer::~CImpIFileViewer
  39. //
  40. //   PURPOSE:   Destructor
  41. //
  42. CImpIFileViewer::~CImpIFileViewer(void)
  43.     {
  44.     return;               
  45.     }
  46. //
  47. //   FUNCTION:     CImpIFileViewer::QueryInterface
  48. //                             CImpIFileViewer::AddRef      
  49. //                             CImpIFileViewer::Release
  50. //
  51. //   PURPOSE:    IUnknown members for CImpIFileViewer object that only delegate.
  52. //
  53. STDMETHODIMP CImpIFileViewer::QueryInterface(REFIID riid
  54.     , PPVOID ppv)
  55.     {
  56.     return m_pUnkOuter->QueryInterface(riid, ppv);
  57.     }
  58.  
  59. STDMETHODIMP_(ULONG) CImpIFileViewer::AddRef(void)
  60.     {
  61.     return m_pUnkOuter->AddRef();
  62.     }
  63.  
  64. STDMETHODIMP_(ULONG) CImpIFileViewer::Release(void)
  65.     {
  66.     return m_pUnkOuter->Release();
  67.     }
  68. //
  69. //   FUNCTION:CImpIFileViewer::PrintTo     
  70. //
  71. //   PURPOSE:    Asks a FileViewer to print the file that came through
  72. //  IPersistFile::Load to a specific device with or without
  73. //  any user interaction.  This function should not return
  74. //  until the printing is complete.
  75. //
  76. //   PARAMETERS: 
  77. //        pszDriver       LPSTR with the path of the driver to use.  If NULL, use the default driver.
  78. //      fSuppressUI     BOOL indicating if this function is to show any    UI or not.
  79. //
  80. //   RETURN VALUE:
  81. //  HRESULT         NOERROR on success, error code otherwise.
  82. //
  83. STDMETHODIMP CImpIFileViewer::PrintTo(LPSTR pszDriver
  84.     , BOOL fSuppressUI)
  85.     {
  86.      // Printing not implemented in this sample, but
  87.      // make a stub call anyway.
  88.     return m_pObj->PrintTo(pszDriver, fSuppressUI);
  89.     }
  90. //
  91. //   FUNCTION: CImpIFileViewer::ShowInitialize    
  92. //
  93. //   PURPOSE:  Initializes everything necessary to display the FileViewer
  94. //  window but does not show it.  The FileViewer should do all
  95. //  the necessary pre-visible work here as this is the only
  96. //  time the FileViewer is allowed to fail. 
  97. //
  98. //   PARAMETERS: 
  99. //
  100. //   RETURN VALUE:
  101. //       HRESULT         NOERROR or an appropriate error code such as
  102. //                  E_UNEXPECTED, E_FAIL, or E_OUTOFMEMORY.
  103. //
  104. STDMETHODIMP CImpIFileViewer::ShowInitialize(LPFILEVIEWERSITE lpfsi)
  105.     {
  106.     return m_pObj->FileShowInit(lpfsi);
  107.     }
  108. //
  109. //   FUNCTION:CImpIFileViewer::Show     
  110. //
  111. //   PURPOSE:    Displays the FileViewer's window in which the file is
  112. //  displayed.  This function cannot be called unless
  113. //  Initialize has already been called.  If Initialize has
  114. //  been called then this function is not allowed to fail and
  115. //  should do little more than show the window and enter a
  116. //  message loop, that is, perform no allocations or anything
  117. //  else that may fail due to low-memory conditions.
  118. //
  119. //  Treat this function like a WinMain function.
  120. //
  121. //   PARAMETERS: 
  122. //        nCmdShow        int indicating how to initially show the FileViewer window.
  123. //
  124. //   RETURN VALUE:
  125. //        HRESULT         E_UNEXPECTED if Initalize has not been called, otherwise must be NOERROR.
  126. //
  127. STDMETHODIMP CImpIFileViewer::Show(LPFVSHOWINFO pvsi)
  128.     {
  129.     if (!m_pObj->m_fShowInit)
  130.         return ResultFromScode(E_UNEXPECTED);
  131.  
  132.     m_pObj->FileShow(pvsi);
  133.     return NOERROR;
  134.     }
  135.