windows-nt/Source/XPSP1/NT/admin/activec/designer/samples/fileviewerextension/fileviewerextension.dsr

860 lines
35 KiB
Plaintext
Raw Normal View History

2020-09-26 03:20:57 -05:00
VERSION 5.00
Begin {B3E55942-FFD8-11D1-9788-44A620524153} FileViewer
ClientHeight = 9330
ClientLeft = 0
ClientTop = 0
ClientWidth = 10740
_ExtentX = 18944
_ExtentY = 16457
m_iNextNodeNumber= 0
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
BeginProperty ImageLists {FFF9A8F6-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 1
KeysOnly = 0
BeginProperty Item1 {87BC1809-C8FB-11D1-B44A-30F4BC000000}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Name = "imgToolbar"
Index = 1
Key = "imgToolbar"
MaskColor = 0
BeginProperty ListImages {87BC180B-C8FB-11D1-B44A-30F4BC000000}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 1
KeysOnly = 0
BeginProperty Item1 {87BC180D-C8FB-11D1-B44A-30F4BC000000}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Index = 1
Key = ""
Tag = "0"
Picture = "FileViewerExtension.dsx":0000
EndProperty
EndProperty
DISPID = 1002
EndProperty
EndProperty
BeginProperty Menus {11517450-27FE-11D3-AA41-00104B880587}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 1
KeysOnly = 0
BeginProperty Item1 {91CC37D5-CE2B-11D1-B44D-7E92AF000000}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Caption = "Menu1"
Visible = -1
Checked = 0
Enabled = -1
Grayed = 0
MenuBreak = 0
MenuBarBreak = 0
Default = 0
Index = 1
Name = "ViewerMenu"
Tag = 0
StatusBarText = ""
BeginProperty Children {11517450-27FE-11D3-AA41-00104B880587}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 1
KeysOnly = 0
BeginProperty Item1 {91CC37D5-CE2B-11D1-B44D-7E92AF000000}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Caption = "View File..."
Visible = -1
Checked = 0
Enabled = -1
Grayed = 0
MenuBreak = 0
MenuBarBreak = 0
Default = 0
Index = 1
Name = "ViewFile"
Tag = 0
StatusBarText = "View the selected file"
BeginProperty Children {11517450-27FE-11D3-AA41-00104B880587}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
Key = "1"
DISPID = 1001
EndProperty
EndProperty
Key = "1"
DISPID = 1000
EndProperty
EndProperty
BeginProperty Toolbars {FFF9A8FA-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 2
KeysOnly = 0
BeginProperty Item1 {91CC37E1-CE2B-11D1-B44D-7E92AF000000}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Index = 1
Key = "tbrViewer"
Name = "tbrViewer"
Tag = "0"
BeginProperty Buttons {8B034115-FBB2-11D1-9785-EAA220524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 1
KeysOnly = 0
BeginProperty Item1 {91CC37E6-CE2B-11D1-B44D-7E92AF000000}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
BeginProperty ButtonMenus {91CC37E7-CE2B-11D1-B44D-7E92AF000000}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
Caption = "View File..."
Enabled = -1
Image = 1
Index = 1
Key = ""
MixedState = 0
Style = 0
Tag = ""
ToolTipText = "View File Contents..."
Value = 0
Visible = -1
EndProperty
EndProperty
Images = "imgToolbar"
DISPID = 1003
EndProperty
BeginProperty Item2 {91CC37E1-CE2B-11D1-B44D-7E92AF000000}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Index = 2
Key = "tbrMenuButton"
Name = "tbrMenuButton"
Tag = 0
BeginProperty Buttons {8B034115-FBB2-11D1-9785-EAA220524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 1
KeysOnly = 0
BeginProperty Item1 {91CC37E6-CE2B-11D1-B44D-7E92AF000000}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
BeginProperty ButtonMenus {91CC37E7-CE2B-11D1-B44D-7E92AF000000}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 1
KeysOnly = 0
BeginProperty Item1 {91CC37E9-CE2B-11D1-B44D-7E92AF000000}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Enabled = -1
Index = 1
Key = ""
Tag = ""
Text = "View File..."
Visible = -1
Checked = 0
Grayed = 0
Separator = 0
MenuBreak = 0
MenuBarBreak = 0
EndProperty
EndProperty
Caption = "FileViewer"
Enabled = -1
Image = ""
Index = 1
Key = ""
MixedState = 0
Style = 16
Tag = ""
ToolTipText = ""
Value = 0
Visible = -1
EndProperty
EndProperty
Images = ""
DISPID = 1004
EndProperty
EndProperty
BeginProperty ViewDefs {FFF9A8E1-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
BeginProperty ListViews {FFF9A8FC-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
BeginProperty OCXViews {FFF9A8FF-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
BeginProperty URLViews {FFF9A902-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
BeginProperty TaskpadViews {FFF9A904-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
EndProperty
BeginProperty DataFormats {91FE14C5-7370-11D2-97D8-00104B880587}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
BeginProperty SnapInDef {FFF9A8E4-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Name = "FileViewer"
NodeTypeName = "FileViewerExtension"
NodeTypeGUID = "{D42F4543-CD95-11d2-97ED-00104B880587}"
DisplayName = "FileViewerExtension"
Type = 1
HelpFile = ""
LinkedTopics = ""
Description = "Visual Basic Sample Extension Snap-in for FileExplorer"
Provider = "Microsoft Corporation"
Version = "1.0"
SmallFolders = ""
SmallFoldersOpen= ""
LargeFolders = ""
Icon = "FileViewerExtension.dsx":0352
Watermark = "FileViewerExtension.dsx":03B0
Header = "FileViewerExtension.dsx":040E
Palette = "FileViewerExtension.dsx":046C
StretchWatermark= 0
StaticFolder = 0
DefaultView = ""
Extensible = 0
BeginProperty ViewDefs {FFF9A8E1-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
BeginProperty ListViews {FFF9A8FC-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 1
EndProperty
BeginProperty OCXViews {FFF9A8FF-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 1
EndProperty
BeginProperty URLViews {FFF9A902-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 1
EndProperty
BeginProperty TaskpadViews {FFF9A904-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 1
EndProperty
EndProperty
BeginProperty Children {FFF9A8F4-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
IID = "{B51C28E4-22E9-4DE4-AD63-18E947617268}"
Preload = 0
EndProperty
BeginProperty ExtensionDefs {FFF9A8E6-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
ExtendsNewMenu = 0
ExtendsTaskMenu = 0
ExtendsTopMenu = 0
ExtendsViewMenu = 0
ExtendsPropertyPages= 0
ExtendsToolbar = 0
ExtendsNameSpace= 0
BeginProperty ExtendedSnapIns {BDA4B9D1-0872-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 3
KeysOnly = 0
BeginProperty Item1 {FFF9A8E8-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Name = ""
Index = 1
Key = "{119067F7-4DBC-11D2-8873-0080C7E0ACE4}"
CLSID = "{119067F7-4DBC-11D2-8873-0080C7E0ACE4}"
DisplayName = "Directory"
Dynamic = 0
ExtendsNameSpace= 0
ExtendsNewMenu = 0
ExtendsTaskMenu = 0
ExtendsPropertyPages= -1
ExtendsToolbar = 0
ExtendsTaskpad = 0
EndProperty
BeginProperty Item2 {FFF9A8E8-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Name = ""
Index = 2
Key = "{873CAEF3-4DA3-11D2-8873-0080C7E0ACE4}"
CLSID = "{873CAEF3-4DA3-11D2-8873-0080C7E0ACE4}"
DisplayName = "FileExplorer"
Dynamic = 0
ExtendsNameSpace= 0
ExtendsNewMenu = 0
ExtendsTaskMenu = 0
ExtendsPropertyPages= 0
ExtendsToolbar = 0
ExtendsTaskpad = -1
EndProperty
BeginProperty Item3 {FFF9A8E8-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Name = ""
Index = 3
Key = "{D2B294B2-9F64-11d2-97E1-00104B880587}"
CLSID = "{D2B294B2-9F64-11d2-97E1-00104B880587}"
DisplayName = "lvExporerFiles"
Dynamic = 0
ExtendsNameSpace= 0
ExtendsNewMenu = 0
ExtendsTaskMenu = -1
ExtendsPropertyPages= -1
ExtendsToolbar = -1
ExtendsTaskpad = 0
EndProperty
EndProperty
EndProperty
BeginProperty AutoCreateNodes {FFF9A8F4-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
BeginProperty OtherNodes {FFF9A8F4-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
TypeinfoCookie = 24
ProjectName = "FileViewerExtensionProj"
End
Attribute VB_Name = "FileViewer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
' ===========================================================================
' | 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 |
' ===========================================================================
' =============================================================================
' File: FileViewerExtension.dsr
' Project: FileViewerExtensionProj
' Type: SnapIn Designer
' =============================================================================
' =============================================================================
' Method: ExtensionSnapIn_AddTaskMenuItems
' Type: Event
' Description: Fired when a context menu is about to be displayed to give the
' extension snap-in the opportunity to add items to MMC's "Task"
' sub-menu.
'
' Parameters: DataObjects An MMCDataObject collection that contains the
' current selection. The extension snap-in must
' interpret the data exported by the extended
' snap-ins (in this case FileExplorer exports the
' data)
' ContextMenu A ContextMenu object that allows adding the
' snap-in's menus.
' Output: None
' Notes: Adds ViewerMenu containing the "View File..." item.
' =============================================================================
'
Private Sub ExtensionSnapIn_AddTaskMenuItems(ByVal DataObjects As SnapInLib.IMMCDataObjects, _
ByVal ContextMenu As SnapInLib.IContextMenu)
On Error GoTo ErrTrap_ExtensionSnapIn_AddTaskMenuItems
' If there is anything other than a single data object then we ignore it
' as FileExplorer exports one MMCDataObject with the format "File" when the
' selected item is a single file.
If DataObjects.Count <> 1 Then
Exit Sub
End If
' If the selected item exports the data format called "File" then it is a
' file and we add our Task menu
If Not DataObjects(1).GetFormat("File") Then
Exit Sub
End If
ContextMenu.AddMenu ViewerMenu
Exit Sub
' Error Handler for this method
ErrTrap_ExtensionSnapIn_AddTaskMenuItems:
DisplayError "ExtensionSnapIn_AddTaskMenuItems"
End Sub
' =============================================================================
' Method: ExtensionSnapIn_AddTasks
' Type: Event
' Description: Fired when a taskpad is about to be displayed to give the
' extension snap-in the opportunity to add its tasks.
'
' Parameters: DataObject An MMCDataObject that contains the currently
' selected scope item. The extension snap-in must
' interpret the data exported by the extended
' snap-in (in this case FileExplorer exports the
' data)
' GroupName The group name of the taskpad. For VB implemented
' taskpads this is the taskpad name assigned in the
' designer.
' Tasks An empty collection of Task objects. The
' extension snap-in must add its tasks to the
' collection.
' Output: None
' Notes: Adds the "About FileViewer" task.
' =============================================================================
'
Private Sub ExtensionSnapIn_AddTasks(ByVal DataObject As SnapInLib.IMMCDataObject, _
ByVal GroupName As String, _
ByVal Tasks As SnapInLib.ITasks)
On Error GoTo ErrTrap_ExtensionSnapIn_AddTasks
' If FileExplorer is displaying its welcome taskpad then add our About task.
If GroupName = "StaticNodeTaskpad" Then
Dim ViewerTask As Task
Set ViewerTask = Tasks.Add
ViewerTask.ActionType = siNotify
ViewerTask.HelpString = "About the FileViewer Extension Sample..."
ViewerTask.ImageType = siSymbol
ViewerTask.FontFamily = "GLYPH 100"
ViewerTask.EOTFile = "res://mmc.exe/glyph100.eot"
ViewerTask.SymbolString = "T"
ViewerTask.Text = "About FileViewer"
End If
Exit Sub
' Error Handler for this method
ErrTrap_ExtensionSnapIn_AddTasks:
DisplayError "ExtensionSnapIn_AddTasks"
End Sub
' =============================================================================
' Method: ExtensionSnapIn_TaskClick
' Type: Event
' Description: Fired when the user clicks a task owned by the extension snap-in
' in a default taskpad owned by the extended snap-in.
'
' Parameters: DataObject An MMCDataObject that contains the currently
' selected scope item. The extension snap-in must
' interpret the data exported by the extended
' snap-in (in this case FileExplorer exports the
' data)
' Task The Task clicked
'
' Output: None
' Notes: We only have one task that displays an "About" message box.
' =============================================================================
'
Private Sub ExtensionSnapIn_TaskClick(ByVal DataObject As SnapInLib.IMMCDataObject, _
ByVal Task As SnapInLib.ITask)
On Error GoTo ErrTrap_ExtensionSnapIn_TaskClick
' Note that as an extension snap-in we do not have access to the
' ConsoleMsgBox method so we need to use a VB message box.
MsgBox "Snap-in Designer for Visual Basic 6.0" & Chr$(13) & Chr$(10) & _
"Sample Extension to the FileExplorer Sample" & Chr$(13) & Chr$(10) & _
"Adds taskpad, context menu, property page, and toolbar extensions.", _
vbOKOnly, "FileViewer"
Exit Sub
' Error Handler for this method
ErrTrap_ExtensionSnapIn_TaskClick:
DisplayError "ExtensionSnapIn_TaskClick"
End Sub
' =============================================================================
' Method: ExtensionSnapIn_CreatePropertyPages
' Type: Event
' Description: Fired when the user requests properties for the selected item.
' Gives the extension snap-in the opportunity to add its pages
' to the property sheet being displayed
' by MMC for the selected item.
'
' Parameters: DataObject An MMCDataObject that contains the currently
' selected scope item. The extension snap-in must
' interpret the data exported by the extended
' snap-in (in this case FileExplorer exports the
' data)
' PropertySheet PropertySheet object used to add the snap-in's
' property pages.
'
' Output: None
' Notes: For files add the ppgViewFile page. For folders add the
' ppgDirStats page.
' An important difference between primary and extensions snap-ins
' is that the extension does not receive a QueryPagesFor event.
' The extension is not required to add pages in this event but
' it will always be fired.
' =============================================================================
'
Private Sub ExtensionSnapIn_CreatePropertyPages(ByVal DataObject As SnapInLib.MMCDataObject, _
ByVal PropertySheet As SnapInLib.MMCPropertySheet)
On Error GoTo ErrTrap_ExtensionSnapIn_CreatePropertyPages
Dim Folders() As String
Dim Folder As String
Dim Files() As String
Dim File As String
Dim i As Integer
' Check the exported data formats to determine the nature of the selected
' items and display the appropriate property pages. For multiple selections pass
' the index of the folder or path as the InitData parameter. The property page will
' receive it in IMMCPropertyPage_Initialize and store it for use later in
' PropertyPage_SelectedControls.
' Use "Viewer: <file name>" as the caption.
If DataObject.GetFormat("File") Then
File = FormatData(DataObject.GetData("File"), 1, siString)
PropertySheet.AddPage "ppgViewFile", "Viewer: " & File
ElseIf DataObject.GetFormat("Files") Then
' Get the "Files" format that contains a string array.
Files = FormatData(DataObject.GetData("Files"), 1, siMultiString)
For i = 1 To UBound(Files)
PropertySheet.AddPage "ppgViewFile", "Viewer: " & Files(i), _
True, False, Str(i)
Next i
End If
' For folders, there is only one piece of data - the folder's path. We pass that
' directly in the InitData parameter.
' Use "Viewer: <folder path>" as the caption.
If DataObject.GetFormat("Folder") Then
Folder = FormatData(DataObject.GetData("Folder"), 1, siString)
PropertySheet.AddPage "ppgDirStats", "Viewer: " & Folder, True, False, Folder
ElseIf DataObject.GetFormat("Folders") Then
Folders = FormatData(DataObject.GetData("Folders"), 1, siMultiString)
For i = 1 To UBound(Folders)
PropertySheet.AddPage "ppgDirStats", "Viewer: " & Folders(i), _
True, False, Folders(i)
Next i
End If
Exit Sub
' Error Handler for this method
ErrTrap_ExtensionSnapIn_CreatePropertyPages:
DisplayError "ExtensionSnapIn_CreatePropertyPages"
End Sub
' =============================================================================
' Method: ExtensionSnapIn_SetControlbar
' Type: Event
' Description: Fired before a view is displayed. It allows an extension snap-in
' to add or remove its toolbars and menu buttons.
' Parameters: Controlbar A reference to the controlling object that
' manages the snap-in's toolbars and menu buttons
' Output: None
' Notes: Add our toolbar and menu button
' =============================================================================
'
Private Sub ExtensionSnapIn_SetControlbar(ByVal Controlbar As SnapInLib.IMMCControlbar)
On Error GoTo ErrTrap_ExtensionSnapIn_SetControlbar
Controlbar.Attach tbrViewer
Controlbar.Attach tbrMenuButton
Exit Sub
' Error Handler for this method
ErrTrap_ExtensionSnapIn_SetControlbar:
DisplayError "ExtensionSnapIn_SetControlbar"
End Sub
' =============================================================================
' Method: ExtensionSnapIn_UpdateControlbar
' Type: Event
' Description: Called following a selection change to allow the snap-in to
' update its toolbar(s) and menu buttons according to the
' selected item(s).
' Parameters: SelectionInScopePane Indicates whether the selection is in the
' scope pane or in the result pane.
' DataObjects An MMCDataObject collection that contains
' the current selection. The extension snap-in
' must interpret the data exported by the
' extended snap-ins (in this case FileExplorer
' exports the data)
' Selected A boolean showing whether the items are
' being selected or de-selected
' Controlbar A reference to the controlling object that
' manages the snap-in's toolbars and menu
' buttons
' Output: None
' Notes: Examine the selection and determine whether to enable the toolbar
' button. Always enable the menu button. If the user clicks
' the menu button we will enable/disable the individual menu
' items according to the selection. (See
' tbrMenuButton_ButtonDropDown above).
' =============================================================================
'
Private Sub ExtensionSnapIn_UpdateControlbar(ByVal SelectionInScopePane As Boolean, _
ByVal Selected As Boolean, _
ByVal DataObjects As SnapInLib.IMMCDataObjects, _
ByVal Controlbar As SnapInLib.IMMCControlbar)
On Error GoTo ErrTrap_ExtensionSnapIn_UpdateControlbar
Dim ButtonEnabled As Boolean
' If the selected item exports the data format called "File" then it is a
' file and we enable our "View File" toolbar button.
If SelectionInScopePane Or _
(Not Selected) Or _
(Not DataObjects(1).GetFormat("File")) Then
ButtonEnabled = False
Else
ButtonEnabled = True
End If
tbrViewer.Buttons(1).Enabled = ButtonEnabled
' Always enable the menu button, but enable/disable the menu item in the drop-down
' based on the selection.
tbrMenuButton.Buttons(1).Enabled = True
tbrMenuButton.Buttons(1).ButtonMenus(1).Grayed = Not ButtonEnabled
Exit Sub
' Error Handler for this method
ErrTrap_ExtensionSnapIn_UpdateControlbar:
DisplayError "ExtensionSnapIn_UpdateControlbar"
End Sub
' =============================================================================
' Method: tbrMenuButton_ButtonMenuClick
' Type: Event
' Description: Fired when a Toolbar button is clicked
'
' Parameters: Selection A reference to an MMCClipboard object that is
' holding a reference to the currently selected
' item(s). Note that even though the selection is
' held in an MMCClipboard object, its ScopeItems and
' ListItems collection will always be empty in an
' extension snap-in because the selected items(s)
' belong to the extended snap-in (FileExplorer in
' this case). The extension snap-in must interpret
' the exported data in MMCClipboard.DataObjects.
' ButtonMenu A reference to the MMCButtonMenu object attached to
' the menu item selected.
' Output: None
' Notes: Calls DisplayFile to do the work.
' =============================================================================
'
Private Sub tbrMenuButton_ButtonMenuClick(ByVal Selection As SnapInLib.IMMCClipboard, _
ByVal ButtonMenu As SnapInLib.IMMCButtonMenu)
DisplayFile Selection
End Sub
' =============================================================================
' Method: tbrViewer_ButtonClick
' Type: Event
' Description: Fired when a Toolbar button is clicked
'
' Parameters: Selection A reference to an MMCClipboard object that is
' holding a reference to the currently selected
' item(s). Note that even though the selection is
' held in an MMCClipboard object, its ScopeItems and
' ListItems collection will always be empty in an
' extension snap-in because the selected items(s)
' belong to the extended snap-in (FileExplorer in
' this case). The extension snap-in must interpret
' the exported data in MMCClipboard.DataObjects.
' Button A reference to the MMCButton object attached to
' the toolbar button clicked.
' Output: None
' Notes: Calls DisplayFile to do the work.
' =============================================================================
'
Private Sub tbrViewer_ButtonClick(ByVal Selection As SnapInLib.IMMCClipboard, _
ByVal Button As SnapInLib.IMMCButton)
DisplayFile Selection
End Sub
' =============================================================================
' Method: ViewFile_Click
' Type: Event
' Description: Fired when the "View File..." context menu item is selected.
'
' Parameters: Index This will always be 1 as we are directly handling
' the event on the individual menu item rather than
' the event on its parent.
' Selection A reference to an MMCClipboard object that is
' holding a reference to the currently selected
' item(s). Note that even though the selection is
' held in an MMCClipboard object, its ScopeItems and
' ListItems collection will always be empty in an
' extension snap-in because the selected items(s)
' belong to the extended snap-in (FileExplorer in
' this case). The extension snap-in must interpret
' the exported data in MMCClipboard.DataObjects.
' Output: None
' Notes: Calls DisplayFile to do the work.
' =============================================================================
'
Private Sub ViewFile_Click(ByVal Index As Long, _
ByVal Selection As SnapInLib.IMMCClipboard)
DisplayFile Selection
End Sub
' =============================================================================
' Method: DisplayFile
' Type: Event
' Description: Fired when the "View File..." context menu item is selected.
'
' Parameters: Selection A reference to an MMCClipboard object that is
' holding a reference to the currently selected
' item(s). Note that even though the selection is
' held in an MMCClipboard object, its ScopeItems and
' ListItems collection will always be empty in an
' extension snap-in because the selected items(s)
' belong to the extended snap-in (FileExplorer in
' this case). The extension snap-in must interpret
' the exported data in MMCClipboard.DataObjects.
' Output: None
' Notes: Gets the file name from the exported data and displays the
' file viewer form
' =============================================================================
'
Private Sub DisplayFile(Selection As MMCClipboard)
On Error GoTo ErrTrap_DisplayFile
Dim FileName As String
Dim Path As String
Dim ViewerForm As frmFileViewer
' If there is anything other than a single data object then we ignore it
' as FileExplorer exports one MMCDataObject with the format "File" when the
' selected item is a single file.
If Selection.DataObjects.Count <> 1 Then
Exit Sub
End If
' If the "File" format is present then extract the name display our form
' with the contents of the file.
If Not Selection.DataObjects(1).GetFormat("File") Then
Exit Sub
End If
FileName = Selection.DataObjects(1).GetData("File")
Path = Selection.DataObjects(1).GetData("Path")
Set ViewerForm = New frmFileViewer
ViewerForm.DisplayFile Path, FileName
Unload ViewerForm
Exit Sub
' Error Handler for this method
ErrTrap_DisplayFile:
DisplayError "DisplayFile"
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)
' Note that as an extension snap-in we do not have access to the
' ConsoleMsgBox method so we need to use a VB message box.
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