Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

220 lines
8.6 KiB

  1. VERSION 5.00
  2. Begin VB.PropertyPage ppgViewFile
  3. Caption = "File Viewer"
  4. ClientHeight = 3600
  5. ClientLeft = 0
  6. ClientTop = 0
  7. ClientWidth = 4800
  8. PaletteMode = 0 'Halftone
  9. ScaleHeight = 3600
  10. ScaleWidth = 4800
  11. Begin FileViewerExtensionProj.ctlFileViewer ViewerCtl
  12. Height = 3615
  13. Left = 0
  14. TabIndex = 0
  15. Top = 0
  16. Width = 4815
  17. _ExtentX = 8493
  18. _ExtentY = 6376
  19. End
  20. End
  21. Attribute VB_Name = "ppgViewFile"
  22. Attribute VB_GlobalNameSpace = False
  23. Attribute VB_Creatable = True
  24. Attribute VB_PredeclaredId = False
  25. Attribute VB_Exposed = True
  26. ' ===========================================================================
  27. ' | THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF |
  28. ' | ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO |
  29. ' | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A |
  30. ' | PARTICULAR PURPOSE. |
  31. ' | Copyright (c) 1998-1999 Microsoft Corporation |
  32. ' ===========================================================================w
  33. ' =============================================================================
  34. ' File: ppgViewFile.pag
  35. ' Project: FileViewerExtensionProj
  36. ' Type: Property Page
  37. ' =============================================================================
  38. Option Explicit
  39. Implements IMMCPropertyPage
  40. ' When the property page is part of a multiple selection this variable holds the
  41. ' index within SelectedControls() of the particular object for which the instance of
  42. ' the property page is being displayed.
  43. Private m_Index As Integer
  44. ' MMC API DLL function declarations
  45. Private Declare Function MMCPropertyHelp Lib "mssnapr.dll" (ByVal HelpTopic As String) As Long
  46. ' =============================================================================
  47. ' Method: IMMCPropertyPage_Initialize
  48. ' Type: Interface method
  49. ' Description: Called when the property page is created to pass the last
  50. ' parameter from MMCPropertySheet.AddPage to the property page
  51. ' Parameters: Data The final parameter from MMCPropertySheet.AddPage
  52. ' Output: None
  53. ' Notes: Store the parameter as the index of the file or folder for
  54. ' which to display the file. Get the file name and initialize
  55. ' the ctlFileViewer control.
  56. ' Unlike a UserControl property page, SelectedControls(0) will
  57. ' contain the MMCDataObject passed to
  58. ' ExtensionSnapIn_CreatePropertyPages so that the property page
  59. ' can access the data exported from the extended snap-in
  60. ' (FileExplorer in this case).
  61. ' =============================================================================
  62. '
  63. Private Sub IMMCPropertyPage_Initialize(ByVal Data As Variant, _
  64. ByVal PropertySheet As SnapInLib.MMCPropertySheet)
  65. On Error GoTo ErrTrap_IMMCPropertyPage_Initialize
  66. Dim FileNames() As String
  67. Dim FileName As String
  68. Dim Paths() As String
  69. Dim Path As String
  70. Dim DataObj As MMCDataObject
  71. Dim Index As Integer
  72. ' Data is only passed when the property sheet is displayed for a multiple selection
  73. If Not VarType(Data) = vbError Then
  74. m_Index = Data
  75. End If
  76. Set DataObj = SelectedControls(0)
  77. ' If there is only one file selected then get its file name and path directly from
  78. ' the exported data. For multiple selection, FileExplorer exports arrays of
  79. ' file names and paths. Use the index stored in IMMCPropertyPage_Initialize as the
  80. ' index into the array (as passed to MMCPropertySheet.AddPage in
  81. ' ExtensionSnapIn_CreatePropertyPages).
  82. If DataObj.GetFormat("File") Then
  83. FileName = DataObj.GetData("File")
  84. Path = DataObj.GetData("Path")
  85. ElseIf DataObj.GetFormat("Files") Then
  86. FileNames = DataObj.FormatData(DataObj.GetData("Files"), 1, siMultiString)
  87. Paths = DataObj.FormatData(DataObj.GetData("Paths"), 1, siMultiString)
  88. Path = Paths(m_Index)
  89. FileName = FileNames(m_Index)
  90. End If
  91. ' Ask FileViewerCtl to display the contents of the file.
  92. ViewerCtl.DisplayFile Path, FileName
  93. Exit Sub
  94. ' Error Handler for this method
  95. ErrTrap_IMMCPropertyPage_Initialize:
  96. DisplayError "IMMCPropertyPage_Initialize"
  97. End Sub
  98. ' =============================================================================
  99. ' Method: IMMCPropertyPage_Help
  100. ' Type: Interface method
  101. ' Description: Called when the user clicks the Help button on a property sheet
  102. '
  103. ' Parameters: None
  104. ' Output: None
  105. ' Notes: Calls the MMC API function MMCPropertyHelp() to display a topic
  106. ' from FileExlporer's merged help file.
  107. ' =============================================================================
  108. '
  109. Private Sub IMMCPropertyPage_Help()
  110. MMCPropertyHelp "VBSnapInsSamples.chm::VBSnapInsSamples/VBSnapInsSamples_35.htm"
  111. End Sub
  112. ' =============================================================================
  113. ' Method: IMMCPropertyPage_GetDialogUnitSize
  114. ' Type: Interface method
  115. ' Description: Called when the property page is about to be created to allow
  116. ' the page to specify its size in dialog units.
  117. '
  118. ' Parameters: None
  119. ' Output: None
  120. ' Notes: Returns the recommended height and width values for a snap-in
  121. ' property page.
  122. ' =============================================================================
  123. '
  124. Private Sub IMMCPropertyPage_GetDialogUnitSize(Height As Variant, Width As Variant)
  125. Height = 218
  126. Width = 252
  127. End Sub
  128. ' =============================================================================
  129. ' Method: IMMCPropertyPage_QueryCancel
  130. ' Type: Interface method
  131. ' Description: Called when the user cancels the property sheet or wizard by
  132. ' pressing Esc, clicking the Cancel button, or clicking the 'X'
  133. ' button in the upper right corner.
  134. '
  135. ' Parameters: Allow - set to False to prevent the sheet or wizard from closing.
  136. ' Output: None
  137. ' Notes: None
  138. ' =============================================================================
  139. '
  140. Private Sub IMMCPropertyPage_QueryCancel(Allow As Boolean)
  141. End Sub
  142. ' =============================================================================
  143. ' Method: IMMCPropertyPage_Cancel
  144. ' Type: Interface method
  145. ' Description: Called when a property sheet or wizard is closed because the
  146. ' user clicked the Cancel button.
  147. '
  148. ' Parameters: None
  149. ' Output: None
  150. ' Notes: None
  151. ' =============================================================================
  152. '
  153. Private Sub IMMCPropertyPage_Cancel()
  154. End Sub
  155. ' =============================================================================
  156. ' Method: IMMCPropertyPage_Close
  157. ' Type: Interface method
  158. ' Description: Called when a property sheet or wizard is closed because the
  159. ' user clicked the 'X' button in the upper right corner.
  160. '
  161. ' Parameters: None
  162. ' Output: None
  163. ' Notes: None
  164. ' =============================================================================
  165. '
  166. Private Sub IMMCPropertyPage_Close()
  167. End Sub
  168. ' =============================================================================
  169. ' Method: DisplayError
  170. ' Type: Subroutine
  171. ' Description: A method to format and display a runtime error
  172. ' Parameters: szLocation A string identifying the source location
  173. ' (i.e. method name) where the error occurred
  174. ' Output: None
  175. ' Notes: The error will be displayed in a messagebox formatted as the
  176. ' following sample:
  177. '
  178. ' Method: SomeMethodName
  179. ' Source: MMCListSubItems
  180. ' Error: 2527h (9511)
  181. ' Description: There is already an item in the collection that has the specified key
  182. '
  183. ' =============================================================================
  184. '
  185. Private Sub DisplayError(szLocation As String)
  186. MsgBox "Method:" & vbTab & vbTab & szLocation & vbCrLf _
  187. & "Source:" & vbTab & vbTab & Err.Source & vbCrLf _
  188. & "Error:" & vbTab & vbTab & Hex(Err.Number) & "h (" & CStr(Err.Number) & ")" & vbCrLf _
  189. & "Description:" & vbTab & Err.Description, _
  190. vbCritical, "FileViewerExtension Runtime Error"
  191. End Sub