Source code of Windows XP (NT5)
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.4 KiB

VERSION 5.00
Begin VB.PropertyPage ppgViewFile
Caption = "File Viewer"
ClientHeight = 3600
ClientLeft = 0
ClientTop = 0
ClientWidth = 4800
PaletteMode = 0 'Halftone
ScaleHeight = 3600
ScaleWidth = 4800
Begin FileViewerExtensionProj.ctlFileViewer ViewerCtl
Height = 3615
Left = 0
TabIndex = 0
Top = 0
Width = 4815
_ExtentX = 8493
_ExtentY = 6376
End
End
Attribute VB_Name = "ppgViewFile"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' ===========================================================================
' | THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF |
' | ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO |
' | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A |
' | PARTICULAR PURPOSE. |
' | Copyright (c) 1998-1999 Microsoft Corporation |
' ===========================================================================w
' =============================================================================
' File: ppgViewFile.pag
' Project: FileViewerExtensionProj
' Type: Property Page
' =============================================================================
Option Explicit
Implements IMMCPropertyPage
' When the property page is part of a multiple selection this variable holds the
' index within SelectedControls() of the particular object for which the instance of
' the property page is being displayed.
Private m_Index As Integer
' MMC API DLL function declarations
Private Declare Function MMCPropertyHelp Lib "mssnapr.dll" (ByVal HelpTopic As String) As Long
' =============================================================================
' Method: IMMCPropertyPage_Initialize
' Type: Interface method
' Description: Called when the property page is created to pass the last
' parameter from MMCPropertySheet.AddPage to the property page
' Parameters: Data The final parameter from MMCPropertySheet.AddPage
' Output: None
' Notes: Store the parameter as the index of the file or folder for
' which to display the file. Get the file name and initialize
' the ctlFileViewer control.
' Unlike a UserControl property page, SelectedControls(0) will
' contain the MMCDataObject passed to
' ExtensionSnapIn_CreatePropertyPages so that the property page
' can access the data exported from the extended snap-in
' (FileExplorer in this case).
' =============================================================================
'
Private Sub IMMCPropertyPage_Initialize(ByVal Data As Variant, _
ByVal PropertySheet As SnapInLib.MMCPropertySheet)
On Error GoTo ErrTrap_IMMCPropertyPage_Initialize
Dim FileNames() As String
Dim FileName As String
Dim Paths() As String
Dim Path As String
Dim DataObj As MMCDataObject
Dim Index As Integer
' Data is only passed when the property sheet is displayed for a multiple selection
If Not VarType(Data) = vbError Then
m_Index = Data
End If
Set DataObj = SelectedControls(0)
' If there is only one file selected then get its file name and path directly from
' the exported data. For multiple selection, FileExplorer exports arrays of
' file names and paths. Use the index stored in IMMCPropertyPage_Initialize as the
' index into the array (as passed to MMCPropertySheet.AddPage in
' ExtensionSnapIn_CreatePropertyPages).
If DataObj.GetFormat("File") Then
FileName = DataObj.GetData("File")
Path = DataObj.GetData("Path")
ElseIf DataObj.GetFormat("Files") Then
FileNames = DataObj.FormatData(DataObj.GetData("Files"), 1, siMultiString)
Paths = DataObj.FormatData(DataObj.GetData("Paths"), 1, siMultiString)
Path = Paths(m_Index)
FileName = FileNames(m_Index)
End If
' Ask FileViewerCtl to display the contents of the file.
ViewerCtl.DisplayFile Path, FileName
Exit Sub
' Error Handler for this method
ErrTrap_IMMCPropertyPage_Initialize:
DisplayError "IMMCPropertyPage_Initialize"
End Sub
' =============================================================================
' Method: IMMCPropertyPage_Help
' Type: Interface method
' Description: Called when the user clicks the Help button on a property sheet
'
' Parameters: None
' Output: None
' Notes: Calls the MMC API function MMCPropertyHelp() to display a topic
' from FileExlporer's merged help file.
' =============================================================================
'
Private Sub IMMCPropertyPage_Help()
MMCPropertyHelp "VBSnapInsSamples.chm::VBSnapInsSamples/VBSnapInsSamples_35.htm"
End Sub
' =============================================================================
' Method: IMMCPropertyPage_GetDialogUnitSize
' Type: Interface method
' Description: Called when the property page is about to be created to allow
' the page to specify its size in dialog units.
'
' Parameters: None
' Output: None
' Notes: Returns the recommended height and width values for a snap-in
' property page.
' =============================================================================
'
Private Sub IMMCPropertyPage_GetDialogUnitSize(Height As Variant, Width As Variant)
Height = 218
Width = 252
End Sub
' =============================================================================
' Method: IMMCPropertyPage_QueryCancel
' Type: Interface method
' Description: Called when the user cancels the property sheet or wizard by
' pressing Esc, clicking the Cancel button, or clicking the 'X'
' button in the upper right corner.
'
' Parameters: Allow - set to False to prevent the sheet or wizard from closing.
' Output: None
' Notes: None
' =============================================================================
'
Private Sub IMMCPropertyPage_QueryCancel(Allow As Boolean)
End Sub
' =============================================================================
' Method: IMMCPropertyPage_Cancel
' Type: Interface method
' Description: Called when a property sheet or wizard is closed because the
' user clicked the Cancel button.
'
' Parameters: None
' Output: None
' Notes: None
' =============================================================================
'
Private Sub IMMCPropertyPage_Cancel()
End Sub
' =============================================================================
' Method: IMMCPropertyPage_Close
' Type: Interface method
' Description: Called when a property sheet or wizard is closed because the
' user clicked the 'X' button in the upper right corner.
'
' Parameters: None
' Output: None
' Notes: None
' =============================================================================
'
Private Sub IMMCPropertyPage_Close()
End Sub
' =============================================================================
' Method: DisplayError
' Type: Subroutine
' Description: A method to format and display a runtime error
' Parameters: szLocation A string identifying the source location
' (i.e. method name) where the error occurred
' Output: None
' Notes: The error will be displayed in a messagebox formatted as the
' following sample:
'
' Method: SomeMethodName
' Source: MMCListSubItems
' Error: 2527h (9511)
' Description: There is already an item in the collection that has the specified key
'
' =============================================================================
'
Private Sub DisplayError(szLocation As String)
MsgBox "Method:" & vbTab & vbTab & szLocation & vbCrLf _
& "Source:" & vbTab & vbTab & Err.Source & vbCrLf _
& "Error:" & vbTab & vbTab & Hex(Err.Number) & "h (" & CStr(Err.Number) & ")" & vbCrLf _
& "Description:" & vbTab & Err.Description, _
vbCritical, "FileViewerExtension Runtime Error"
End Sub