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.

859 lines
36 KiB

  1. VERSION 5.00
  2. Begin {B3E55942-FFD8-11D1-9788-44A620524153} FileViewer
  3. ClientHeight = 9330
  4. ClientLeft = 0
  5. ClientTop = 0
  6. ClientWidth = 10740
  7. _ExtentX = 18944
  8. _ExtentY = 16457
  9. m_iNextNodeNumber= 0
  10. Persistence.MajorVersion= 0
  11. Persistence.MinorVersion= 12
  12. BeginProperty ImageLists {FFF9A8F6-06CB-11D2-9791-50C320524153}
  13. Persistence.MajorVersion= 0
  14. Persistence.MinorVersion= 12
  15. Count = 1
  16. KeysOnly = 0
  17. BeginProperty Item1 {87BC1809-C8FB-11D1-B44A-30F4BC000000}
  18. Persistence.MajorVersion= 0
  19. Persistence.MinorVersion= 12
  20. Name = "imgToolbar"
  21. Index = 1
  22. Key = "imgToolbar"
  23. MaskColor = 0
  24. BeginProperty ListImages {87BC180B-C8FB-11D1-B44A-30F4BC000000}
  25. Persistence.MajorVersion= 0
  26. Persistence.MinorVersion= 12
  27. Count = 1
  28. KeysOnly = 0
  29. BeginProperty Item1 {87BC180D-C8FB-11D1-B44A-30F4BC000000}
  30. Persistence.MajorVersion= 0
  31. Persistence.MinorVersion= 12
  32. Index = 1
  33. Key = ""
  34. Tag = "0"
  35. Picture = "FileViewerExtension.dsx":0000
  36. EndProperty
  37. EndProperty
  38. DISPID = 1002
  39. EndProperty
  40. EndProperty
  41. BeginProperty Menus {11517450-27FE-11D3-AA41-00104B880587}
  42. Persistence.MajorVersion= 0
  43. Persistence.MinorVersion= 12
  44. Count = 1
  45. KeysOnly = 0
  46. BeginProperty Item1 {91CC37D5-CE2B-11D1-B44D-7E92AF000000}
  47. Persistence.MajorVersion= 0
  48. Persistence.MinorVersion= 12
  49. Caption = "Menu1"
  50. Visible = -1
  51. Checked = 0
  52. Enabled = -1
  53. Grayed = 0
  54. MenuBreak = 0
  55. MenuBarBreak = 0
  56. Default = 0
  57. Index = 1
  58. Name = "ViewerMenu"
  59. Tag = 0
  60. StatusBarText = ""
  61. BeginProperty Children {11517450-27FE-11D3-AA41-00104B880587}
  62. Persistence.MajorVersion= 0
  63. Persistence.MinorVersion= 12
  64. Count = 1
  65. KeysOnly = 0
  66. BeginProperty Item1 {91CC37D5-CE2B-11D1-B44D-7E92AF000000}
  67. Persistence.MajorVersion= 0
  68. Persistence.MinorVersion= 12
  69. Caption = "View File..."
  70. Visible = -1
  71. Checked = 0
  72. Enabled = -1
  73. Grayed = 0
  74. MenuBreak = 0
  75. MenuBarBreak = 0
  76. Default = 0
  77. Index = 1
  78. Name = "ViewFile"
  79. Tag = 0
  80. StatusBarText = "View the selected file"
  81. BeginProperty Children {11517450-27FE-11D3-AA41-00104B880587}
  82. Persistence.MajorVersion= 0
  83. Persistence.MinorVersion= 12
  84. Count = 0
  85. KeysOnly = 0
  86. EndProperty
  87. Key = "1"
  88. DISPID = 1001
  89. EndProperty
  90. EndProperty
  91. Key = "1"
  92. DISPID = 1000
  93. EndProperty
  94. EndProperty
  95. BeginProperty Toolbars {FFF9A8FA-06CB-11D2-9791-50C320524153}
  96. Persistence.MajorVersion= 0
  97. Persistence.MinorVersion= 12
  98. Count = 2
  99. KeysOnly = 0
  100. BeginProperty Item1 {91CC37E1-CE2B-11D1-B44D-7E92AF000000}
  101. Persistence.MajorVersion= 0
  102. Persistence.MinorVersion= 12
  103. Index = 1
  104. Key = "tbrViewer"
  105. Name = "tbrViewer"
  106. Tag = "0"
  107. BeginProperty Buttons {8B034115-FBB2-11D1-9785-EAA220524153}
  108. Persistence.MajorVersion= 0
  109. Persistence.MinorVersion= 12
  110. Count = 1
  111. KeysOnly = 0
  112. BeginProperty Item1 {91CC37E6-CE2B-11D1-B44D-7E92AF000000}
  113. Persistence.MajorVersion= 0
  114. Persistence.MinorVersion= 12
  115. BeginProperty ButtonMenus {91CC37E7-CE2B-11D1-B44D-7E92AF000000}
  116. Persistence.MajorVersion= 0
  117. Persistence.MinorVersion= 12
  118. Count = 0
  119. KeysOnly = 0
  120. EndProperty
  121. Caption = "View File..."
  122. Enabled = -1
  123. Image = 1
  124. Index = 1
  125. Key = ""
  126. MixedState = 0
  127. Style = 0
  128. Tag = ""
  129. ToolTipText = "View File Contents..."
  130. Value = 0
  131. Visible = -1
  132. EndProperty
  133. EndProperty
  134. Images = "imgToolbar"
  135. DISPID = 1003
  136. EndProperty
  137. BeginProperty Item2 {91CC37E1-CE2B-11D1-B44D-7E92AF000000}
  138. Persistence.MajorVersion= 0
  139. Persistence.MinorVersion= 12
  140. Index = 2
  141. Key = "tbrMenuButton"
  142. Name = "tbrMenuButton"
  143. Tag = 0
  144. BeginProperty Buttons {8B034115-FBB2-11D1-9785-EAA220524153}
  145. Persistence.MajorVersion= 0
  146. Persistence.MinorVersion= 12
  147. Count = 1
  148. KeysOnly = 0
  149. BeginProperty Item1 {91CC37E6-CE2B-11D1-B44D-7E92AF000000}
  150. Persistence.MajorVersion= 0
  151. Persistence.MinorVersion= 12
  152. BeginProperty ButtonMenus {91CC37E7-CE2B-11D1-B44D-7E92AF000000}
  153. Persistence.MajorVersion= 0
  154. Persistence.MinorVersion= 12
  155. Count = 1
  156. KeysOnly = 0
  157. BeginProperty Item1 {91CC37E9-CE2B-11D1-B44D-7E92AF000000}
  158. Persistence.MajorVersion= 0
  159. Persistence.MinorVersion= 12
  160. Enabled = -1
  161. Index = 1
  162. Key = ""
  163. Tag = ""
  164. Text = "View File..."
  165. Visible = -1
  166. Checked = 0
  167. Grayed = 0
  168. Separator = 0
  169. MenuBreak = 0
  170. MenuBarBreak = 0
  171. EndProperty
  172. EndProperty
  173. Caption = "FileViewer"
  174. Enabled = -1
  175. Image = ""
  176. Index = 1
  177. Key = ""
  178. MixedState = 0
  179. Style = 16
  180. Tag = ""
  181. ToolTipText = ""
  182. Value = 0
  183. Visible = -1
  184. EndProperty
  185. EndProperty
  186. Images = ""
  187. DISPID = 1004
  188. EndProperty
  189. EndProperty
  190. BeginProperty ViewDefs {FFF9A8E1-06CB-11D2-9791-50C320524153}
  191. Persistence.MajorVersion= 0
  192. Persistence.MinorVersion= 12
  193. BeginProperty ListViews {FFF9A8FC-06CB-11D2-9791-50C320524153}
  194. Persistence.MajorVersion= 0
  195. Persistence.MinorVersion= 12
  196. Count = 0
  197. KeysOnly = 0
  198. EndProperty
  199. BeginProperty OCXViews {FFF9A8FF-06CB-11D2-9791-50C320524153}
  200. Persistence.MajorVersion= 0
  201. Persistence.MinorVersion= 12
  202. Count = 0
  203. KeysOnly = 0
  204. EndProperty
  205. BeginProperty URLViews {FFF9A902-06CB-11D2-9791-50C320524153}
  206. Persistence.MajorVersion= 0
  207. Persistence.MinorVersion= 12
  208. Count = 0
  209. KeysOnly = 0
  210. EndProperty
  211. BeginProperty TaskpadViews {FFF9A904-06CB-11D2-9791-50C320524153}
  212. Persistence.MajorVersion= 0
  213. Persistence.MinorVersion= 12
  214. Count = 0
  215. KeysOnly = 0
  216. EndProperty
  217. EndProperty
  218. BeginProperty DataFormats {91FE14C5-7370-11D2-97D8-00104B880587}
  219. Persistence.MajorVersion= 0
  220. Persistence.MinorVersion= 12
  221. Count = 0
  222. KeysOnly = 0
  223. EndProperty
  224. BeginProperty SnapInDef {FFF9A8E4-06CB-11D2-9791-50C320524153}
  225. Persistence.MajorVersion= 0
  226. Persistence.MinorVersion= 12
  227. Name = "FileViewer"
  228. NodeTypeName = "FileViewerExtension"
  229. NodeTypeGUID = "{D42F4543-CD95-11d2-97ED-00104B880587}"
  230. DisplayName = "FileViewerExtension"
  231. Type = 1
  232. HelpFile = ""
  233. LinkedTopics = ""
  234. Description = "Visual Basic Sample Extension Snap-in for FileExplorer"
  235. Provider = "Microsoft Corporation"
  236. Version = "1.0"
  237. SmallFolders = ""
  238. SmallFoldersOpen= ""
  239. LargeFolders = ""
  240. Icon = "FileViewerExtension.dsx":0352
  241. Watermark = "FileViewerExtension.dsx":03B0
  242. Header = "FileViewerExtension.dsx":040E
  243. Palette = "FileViewerExtension.dsx":046C
  244. StretchWatermark= 0
  245. StaticFolder = 0
  246. DefaultView = ""
  247. Extensible = 0
  248. BeginProperty ViewDefs {FFF9A8E1-06CB-11D2-9791-50C320524153}
  249. Persistence.MajorVersion= 0
  250. Persistence.MinorVersion= 12
  251. BeginProperty ListViews {FFF9A8FC-06CB-11D2-9791-50C320524153}
  252. Persistence.MajorVersion= 0
  253. Persistence.MinorVersion= 12
  254. Count = 0
  255. KeysOnly = 1
  256. EndProperty
  257. BeginProperty OCXViews {FFF9A8FF-06CB-11D2-9791-50C320524153}
  258. Persistence.MajorVersion= 0
  259. Persistence.MinorVersion= 12
  260. Count = 0
  261. KeysOnly = 1
  262. EndProperty
  263. BeginProperty URLViews {FFF9A902-06CB-11D2-9791-50C320524153}
  264. Persistence.MajorVersion= 0
  265. Persistence.MinorVersion= 12
  266. Count = 0
  267. KeysOnly = 1
  268. EndProperty
  269. BeginProperty TaskpadViews {FFF9A904-06CB-11D2-9791-50C320524153}
  270. Persistence.MajorVersion= 0
  271. Persistence.MinorVersion= 12
  272. Count = 0
  273. KeysOnly = 1
  274. EndProperty
  275. EndProperty
  276. BeginProperty Children {FFF9A8F4-06CB-11D2-9791-50C320524153}
  277. Persistence.MajorVersion= 0
  278. Persistence.MinorVersion= 12
  279. Count = 0
  280. KeysOnly = 0
  281. EndProperty
  282. IID = "{B51C28E4-22E9-4DE4-AD63-18E947617268}"
  283. Preload = 0
  284. EndProperty
  285. BeginProperty ExtensionDefs {FFF9A8E6-06CB-11D2-9791-50C320524153}
  286. Persistence.MajorVersion= 0
  287. Persistence.MinorVersion= 12
  288. ExtendsNewMenu = 0
  289. ExtendsTaskMenu = 0
  290. ExtendsTopMenu = 0
  291. ExtendsViewMenu = 0
  292. ExtendsPropertyPages= 0
  293. ExtendsToolbar = 0
  294. ExtendsNameSpace= 0
  295. BeginProperty ExtendedSnapIns {BDA4B9D1-0872-11D2-9791-50C320524153}
  296. Persistence.MajorVersion= 0
  297. Persistence.MinorVersion= 12
  298. Count = 3
  299. KeysOnly = 0
  300. BeginProperty Item1 {FFF9A8E8-06CB-11D2-9791-50C320524153}
  301. Persistence.MajorVersion= 0
  302. Persistence.MinorVersion= 12
  303. Name = ""
  304. Index = 1
  305. Key = "{119067F7-4DBC-11D2-8873-0080C7E0ACE4}"
  306. CLSID = "{119067F7-4DBC-11D2-8873-0080C7E0ACE4}"
  307. DisplayName = "Directory"
  308. Dynamic = 0
  309. ExtendsNameSpace= 0
  310. ExtendsNewMenu = 0
  311. ExtendsTaskMenu = 0
  312. ExtendsPropertyPages= -1
  313. ExtendsToolbar = 0
  314. ExtendsTaskpad = 0
  315. EndProperty
  316. BeginProperty Item2 {FFF9A8E8-06CB-11D2-9791-50C320524153}
  317. Persistence.MajorVersion= 0
  318. Persistence.MinorVersion= 12
  319. Name = ""
  320. Index = 2
  321. Key = "{873CAEF3-4DA3-11D2-8873-0080C7E0ACE4}"
  322. CLSID = "{873CAEF3-4DA3-11D2-8873-0080C7E0ACE4}"
  323. DisplayName = "FileExplorer"
  324. Dynamic = 0
  325. ExtendsNameSpace= 0
  326. ExtendsNewMenu = 0
  327. ExtendsTaskMenu = 0
  328. ExtendsPropertyPages= 0
  329. ExtendsToolbar = 0
  330. ExtendsTaskpad = -1
  331. EndProperty
  332. BeginProperty Item3 {FFF9A8E8-06CB-11D2-9791-50C320524153}
  333. Persistence.MajorVersion= 0
  334. Persistence.MinorVersion= 12
  335. Name = ""
  336. Index = 3
  337. Key = "{D2B294B2-9F64-11d2-97E1-00104B880587}"
  338. CLSID = "{D2B294B2-9F64-11d2-97E1-00104B880587}"
  339. DisplayName = "lvExporerFiles"
  340. Dynamic = 0
  341. ExtendsNameSpace= 0
  342. ExtendsNewMenu = 0
  343. ExtendsTaskMenu = -1
  344. ExtendsPropertyPages= -1
  345. ExtendsToolbar = -1
  346. ExtendsTaskpad = 0
  347. EndProperty
  348. EndProperty
  349. EndProperty
  350. BeginProperty AutoCreateNodes {FFF9A8F4-06CB-11D2-9791-50C320524153}
  351. Persistence.MajorVersion= 0
  352. Persistence.MinorVersion= 12
  353. Count = 0
  354. KeysOnly = 0
  355. EndProperty
  356. BeginProperty OtherNodes {FFF9A8F4-06CB-11D2-9791-50C320524153}
  357. Persistence.MajorVersion= 0
  358. Persistence.MinorVersion= 12
  359. Count = 0
  360. KeysOnly = 0
  361. EndProperty
  362. TypeinfoCookie = 24
  363. ProjectName = "FileViewerExtensionProj"
  364. End
  365. Attribute VB_Name = "FileViewer"
  366. Attribute VB_GlobalNameSpace = False
  367. Attribute VB_Creatable = True
  368. Attribute VB_PredeclaredId = False
  369. Attribute VB_Exposed = True
  370. Option Explicit
  371. ' ===========================================================================
  372. ' | THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF |
  373. ' | ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO |
  374. ' | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A |
  375. ' | PARTICULAR PURPOSE. |
  376. ' | Copyright (c) 1998-1999 Microsoft Corporation |
  377. ' ===========================================================================
  378. ' =============================================================================
  379. ' File: FileViewerExtension.dsr
  380. ' Project: FileViewerExtensionProj
  381. ' Type: SnapIn Designer
  382. ' =============================================================================
  383. ' =============================================================================
  384. ' Method: ExtensionSnapIn_AddTaskMenuItems
  385. ' Type: Event
  386. ' Description: Fired when a context menu is about to be displayed to give the
  387. ' extension snap-in the opportunity to add items to MMC's "Task"
  388. ' sub-menu.
  389. '
  390. ' Parameters: DataObjects An MMCDataObject collection that contains the
  391. ' current selection. The extension snap-in must
  392. ' interpret the data exported by the extended
  393. ' snap-ins (in this case FileExplorer exports the
  394. ' data)
  395. ' ContextMenu A ContextMenu object that allows adding the
  396. ' snap-in's menus.
  397. ' Output: None
  398. ' Notes: Adds ViewerMenu containing the "View File..." item.
  399. ' =============================================================================
  400. '
  401. Private Sub ExtensionSnapIn_AddTaskMenuItems(ByVal DataObjects As SnapInLib.IMMCDataObjects, _
  402. ByVal ContextMenu As SnapInLib.IContextMenu)
  403. On Error GoTo ErrTrap_ExtensionSnapIn_AddTaskMenuItems
  404. ' If there is anything other than a single data object then we ignore it
  405. ' as FileExplorer exports one MMCDataObject with the format "File" when the
  406. ' selected item is a single file.
  407. If DataObjects.Count <> 1 Then
  408. Exit Sub
  409. End If
  410. ' If the selected item exports the data format called "File" then it is a
  411. ' file and we add our Task menu
  412. If Not DataObjects(1).GetFormat("File") Then
  413. Exit Sub
  414. End If
  415. ContextMenu.AddMenu ViewerMenu
  416. Exit Sub
  417. ' Error Handler for this method
  418. ErrTrap_ExtensionSnapIn_AddTaskMenuItems:
  419. DisplayError "ExtensionSnapIn_AddTaskMenuItems"
  420. End Sub
  421. ' =============================================================================
  422. ' Method: ExtensionSnapIn_AddTasks
  423. ' Type: Event
  424. ' Description: Fired when a taskpad is about to be displayed to give the
  425. ' extension snap-in the opportunity to add its tasks.
  426. '
  427. ' Parameters: DataObject An MMCDataObject that contains the currently
  428. ' selected scope item. The extension snap-in must
  429. ' interpret the data exported by the extended
  430. ' snap-in (in this case FileExplorer exports the
  431. ' data)
  432. ' GroupName The group name of the taskpad. For VB implemented
  433. ' taskpads this is the taskpad name assigned in the
  434. ' designer.
  435. ' Tasks An empty collection of Task objects. The
  436. ' extension snap-in must add its tasks to the
  437. ' collection.
  438. ' Output: None
  439. ' Notes: Adds the "About FileViewer" task.
  440. ' =============================================================================
  441. '
  442. Private Sub ExtensionSnapIn_AddTasks(ByVal DataObject As SnapInLib.IMMCDataObject, _
  443. ByVal GroupName As String, _
  444. ByVal Tasks As SnapInLib.ITasks)
  445. On Error GoTo ErrTrap_ExtensionSnapIn_AddTasks
  446. ' If FileExplorer is displaying its welcome taskpad then add our About task.
  447. If GroupName = "StaticNodeTaskpad" Then
  448. Dim ViewerTask As Task
  449. Set ViewerTask = Tasks.Add
  450. ViewerTask.ActionType = siNotify
  451. ViewerTask.HelpString = "About the FileViewer Extension Sample..."
  452. ViewerTask.ImageType = siSymbol
  453. ViewerTask.FontFamily = "GLYPH 100"
  454. ViewerTask.EOTFile = "res://mmc.exe/glyph100.eot"
  455. ViewerTask.SymbolString = "T"
  456. ViewerTask.Text = "About FileViewer"
  457. End If
  458. Exit Sub
  459. ' Error Handler for this method
  460. ErrTrap_ExtensionSnapIn_AddTasks:
  461. DisplayError "ExtensionSnapIn_AddTasks"
  462. End Sub
  463. ' =============================================================================
  464. ' Method: ExtensionSnapIn_TaskClick
  465. ' Type: Event
  466. ' Description: Fired when the user clicks a task owned by the extension snap-in
  467. ' in a default taskpad owned by the extended snap-in.
  468. '
  469. ' Parameters: DataObject An MMCDataObject that contains the currently
  470. ' selected scope item. The extension snap-in must
  471. ' interpret the data exported by the extended
  472. ' snap-in (in this case FileExplorer exports the
  473. ' data)
  474. ' Task The Task clicked
  475. '
  476. ' Output: None
  477. ' Notes: We only have one task that displays an "About" message box.
  478. ' =============================================================================
  479. '
  480. Private Sub ExtensionSnapIn_TaskClick(ByVal DataObject As SnapInLib.IMMCDataObject, _
  481. ByVal Task As SnapInLib.ITask)
  482. On Error GoTo ErrTrap_ExtensionSnapIn_TaskClick
  483. ' Note that as an extension snap-in we do not have access to the
  484. ' ConsoleMsgBox method so we need to use a VB message box.
  485. MsgBox "Snap-in Designer for Visual Basic 6.0" & Chr$(13) & Chr$(10) & _
  486. "Sample Extension to the FileExplorer Sample" & Chr$(13) & Chr$(10) & _
  487. "Adds taskpad, context menu, property page, and toolbar extensions.", _
  488. vbOKOnly, "FileViewer"
  489. Exit Sub
  490. ' Error Handler for this method
  491. ErrTrap_ExtensionSnapIn_TaskClick:
  492. DisplayError "ExtensionSnapIn_TaskClick"
  493. End Sub
  494. ' =============================================================================
  495. ' Method: ExtensionSnapIn_CreatePropertyPages
  496. ' Type: Event
  497. ' Description: Fired when the user requests properties for the selected item.
  498. ' Gives the extension snap-in the opportunity to add its pages
  499. ' to the property sheet being displayed
  500. ' by MMC for the selected item.
  501. '
  502. ' Parameters: DataObject An MMCDataObject that contains the currently
  503. ' selected scope item. The extension snap-in must
  504. ' interpret the data exported by the extended
  505. ' snap-in (in this case FileExplorer exports the
  506. ' data)
  507. ' PropertySheet PropertySheet object used to add the snap-in's
  508. ' property pages.
  509. '
  510. ' Output: None
  511. ' Notes: For files add the ppgViewFile page. For folders add the
  512. ' ppgDirStats page.
  513. ' An important difference between primary and extensions snap-ins
  514. ' is that the extension does not receive a QueryPagesFor event.
  515. ' The extension is not required to add pages in this event but
  516. ' it will always be fired.
  517. ' =============================================================================
  518. '
  519. Private Sub ExtensionSnapIn_CreatePropertyPages(ByVal DataObject As SnapInLib.MMCDataObject, _
  520. ByVal PropertySheet As SnapInLib.MMCPropertySheet)
  521. On Error GoTo ErrTrap_ExtensionSnapIn_CreatePropertyPages
  522. Dim Folders() As String
  523. Dim Folder As String
  524. Dim Files() As String
  525. Dim File As String
  526. Dim i As Integer
  527. ' Check the exported data formats to determine the nature of the selected
  528. ' items and display the appropriate property pages. For multiple selections pass
  529. ' the index of the folder or path as the InitData parameter. The property page will
  530. ' receive it in IMMCPropertyPage_Initialize and store it for use later in
  531. ' PropertyPage_SelectedControls.
  532. ' Use "Viewer: <file name>" as the caption.
  533. If DataObject.GetFormat("File") Then
  534. File = FormatData(DataObject.GetData("File"), 1, siString)
  535. PropertySheet.AddPage "ppgViewFile", "Viewer: " & File
  536. ElseIf DataObject.GetFormat("Files") Then
  537. ' Get the "Files" format that contains a string array.
  538. Files = FormatData(DataObject.GetData("Files"), 1, siMultiString)
  539. For i = 1 To UBound(Files)
  540. PropertySheet.AddPage "ppgViewFile", "Viewer: " & Files(i), _
  541. True, False, Str(i)
  542. Next i
  543. End If
  544. ' For folders, there is only one piece of data - the folder's path. We pass that
  545. ' directly in the InitData parameter.
  546. ' Use "Viewer: <folder path>" as the caption.
  547. If DataObject.GetFormat("Folder") Then
  548. Folder = FormatData(DataObject.GetData("Folder"), 1, siString)
  549. PropertySheet.AddPage "ppgDirStats", "Viewer: " & Folder, True, False, Folder
  550. ElseIf DataObject.GetFormat("Folders") Then
  551. Folders = FormatData(DataObject.GetData("Folders"), 1, siMultiString)
  552. For i = 1 To UBound(Folders)
  553. PropertySheet.AddPage "ppgDirStats", "Viewer: " & Folders(i), _
  554. True, False, Folders(i)
  555. Next i
  556. End If
  557. Exit Sub
  558. ' Error Handler for this method
  559. ErrTrap_ExtensionSnapIn_CreatePropertyPages:
  560. DisplayError "ExtensionSnapIn_CreatePropertyPages"
  561. End Sub
  562. ' =============================================================================
  563. ' Method: ExtensionSnapIn_SetControlbar
  564. ' Type: Event
  565. ' Description: Fired before a view is displayed. It allows an extension snap-in
  566. ' to add or remove its toolbars and menu buttons.
  567. ' Parameters: Controlbar A reference to the controlling object that
  568. ' manages the snap-in's toolbars and menu buttons
  569. ' Output: None
  570. ' Notes: Add our toolbar and menu button
  571. ' =============================================================================
  572. '
  573. Private Sub ExtensionSnapIn_SetControlbar(ByVal Controlbar As SnapInLib.IMMCControlbar)
  574. On Error GoTo ErrTrap_ExtensionSnapIn_SetControlbar
  575. Controlbar.Attach tbrViewer
  576. Controlbar.Attach tbrMenuButton
  577. Exit Sub
  578. ' Error Handler for this method
  579. ErrTrap_ExtensionSnapIn_SetControlbar:
  580. DisplayError "ExtensionSnapIn_SetControlbar"
  581. End Sub
  582. ' =============================================================================
  583. ' Method: ExtensionSnapIn_UpdateControlbar
  584. ' Type: Event
  585. ' Description: Called following a selection change to allow the snap-in to
  586. ' update its toolbar(s) and menu buttons according to the
  587. ' selected item(s).
  588. ' Parameters: SelectionInScopePane Indicates whether the selection is in the
  589. ' scope pane or in the result pane.
  590. ' DataObjects An MMCDataObject collection that contains
  591. ' the current selection. The extension snap-in
  592. ' must interpret the data exported by the
  593. ' extended snap-ins (in this case FileExplorer
  594. ' exports the data)
  595. ' Selected A boolean showing whether the items are
  596. ' being selected or de-selected
  597. ' Controlbar A reference to the controlling object that
  598. ' manages the snap-in's toolbars and menu
  599. ' buttons
  600. ' Output: None
  601. ' Notes: Examine the selection and determine whether to enable the toolbar
  602. ' button. Always enable the menu button. If the user clicks
  603. ' the menu button we will enable/disable the individual menu
  604. ' items according to the selection. (See
  605. ' tbrMenuButton_ButtonDropDown above).
  606. ' =============================================================================
  607. '
  608. Private Sub ExtensionSnapIn_UpdateControlbar(ByVal SelectionInScopePane As Boolean, _
  609. ByVal Selected As Boolean, _
  610. ByVal DataObjects As SnapInLib.IMMCDataObjects, _
  611. ByVal Controlbar As SnapInLib.IMMCControlbar)
  612. On Error GoTo ErrTrap_ExtensionSnapIn_UpdateControlbar
  613. Dim ButtonEnabled As Boolean
  614. ' If the selected item exports the data format called "File" then it is a
  615. ' file and we enable our "View File" toolbar button.
  616. If SelectionInScopePane Or _
  617. (Not Selected) Or _
  618. (Not DataObjects(1).GetFormat("File")) Then
  619. ButtonEnabled = False
  620. Else
  621. ButtonEnabled = True
  622. End If
  623. tbrViewer.Buttons(1).Enabled = ButtonEnabled
  624. ' Always enable the menu button, but enable/disable the menu item in the drop-down
  625. ' based on the selection.
  626. tbrMenuButton.Buttons(1).Enabled = True
  627. tbrMenuButton.Buttons(1).ButtonMenus(1).Grayed = Not ButtonEnabled
  628. Exit Sub
  629. ' Error Handler for this method
  630. ErrTrap_ExtensionSnapIn_UpdateControlbar:
  631. DisplayError "ExtensionSnapIn_UpdateControlbar"
  632. End Sub
  633. ' =============================================================================
  634. ' Method: tbrMenuButton_ButtonMenuClick
  635. ' Type: Event
  636. ' Description: Fired when a Toolbar button is clicked
  637. '
  638. ' Parameters: Selection A reference to an MMCClipboard object that is
  639. ' holding a reference to the currently selected
  640. ' item(s). Note that even though the selection is
  641. ' held in an MMCClipboard object, its ScopeItems and
  642. ' ListItems collection will always be empty in an
  643. ' extension snap-in because the selected items(s)
  644. ' belong to the extended snap-in (FileExplorer in
  645. ' this case). The extension snap-in must interpret
  646. ' the exported data in MMCClipboard.DataObjects.
  647. ' ButtonMenu A reference to the MMCButtonMenu object attached to
  648. ' the menu item selected.
  649. ' Output: None
  650. ' Notes: Calls DisplayFile to do the work.
  651. ' =============================================================================
  652. '
  653. Private Sub tbrMenuButton_ButtonMenuClick(ByVal Selection As SnapInLib.IMMCClipboard, _
  654. ByVal ButtonMenu As SnapInLib.IMMCButtonMenu)
  655. DisplayFile Selection
  656. End Sub
  657. ' =============================================================================
  658. ' Method: tbrViewer_ButtonClick
  659. ' Type: Event
  660. ' Description: Fired when a Toolbar button is clicked
  661. '
  662. ' Parameters: Selection A reference to an MMCClipboard object that is
  663. ' holding a reference to the currently selected
  664. ' item(s). Note that even though the selection is
  665. ' held in an MMCClipboard object, its ScopeItems and
  666. ' ListItems collection will always be empty in an
  667. ' extension snap-in because the selected items(s)
  668. ' belong to the extended snap-in (FileExplorer in
  669. ' this case). The extension snap-in must interpret
  670. ' the exported data in MMCClipboard.DataObjects.
  671. ' Button A reference to the MMCButton object attached to
  672. ' the toolbar button clicked.
  673. ' Output: None
  674. ' Notes: Calls DisplayFile to do the work.
  675. ' =============================================================================
  676. '
  677. Private Sub tbrViewer_ButtonClick(ByVal Selection As SnapInLib.IMMCClipboard, _
  678. ByVal Button As SnapInLib.IMMCButton)
  679. DisplayFile Selection
  680. End Sub
  681. ' =============================================================================
  682. ' Method: ViewFile_Click
  683. ' Type: Event
  684. ' Description: Fired when the "View File..." context menu item is selected.
  685. '
  686. ' Parameters: Index This will always be 1 as we are directly handling
  687. ' the event on the individual menu item rather than
  688. ' the event on its parent.
  689. ' Selection A reference to an MMCClipboard object that is
  690. ' holding a reference to the currently selected
  691. ' item(s). Note that even though the selection is
  692. ' held in an MMCClipboard object, its ScopeItems and
  693. ' ListItems collection will always be empty in an
  694. ' extension snap-in because the selected items(s)
  695. ' belong to the extended snap-in (FileExplorer in
  696. ' this case). The extension snap-in must interpret
  697. ' the exported data in MMCClipboard.DataObjects.
  698. ' Output: None
  699. ' Notes: Calls DisplayFile to do the work.
  700. ' =============================================================================
  701. '
  702. Private Sub ViewFile_Click(ByVal Index As Long, _
  703. ByVal Selection As SnapInLib.IMMCClipboard)
  704. DisplayFile Selection
  705. End Sub
  706. ' =============================================================================
  707. ' Method: DisplayFile
  708. ' Type: Event
  709. ' Description: Fired when the "View File..." context menu item is selected.
  710. '
  711. ' Parameters: Selection A reference to an MMCClipboard object that is
  712. ' holding a reference to the currently selected
  713. ' item(s). Note that even though the selection is
  714. ' held in an MMCClipboard object, its ScopeItems and
  715. ' ListItems collection will always be empty in an
  716. ' extension snap-in because the selected items(s)
  717. ' belong to the extended snap-in (FileExplorer in
  718. ' this case). The extension snap-in must interpret
  719. ' the exported data in MMCClipboard.DataObjects.
  720. ' Output: None
  721. ' Notes: Gets the file name from the exported data and displays the
  722. ' file viewer form
  723. ' =============================================================================
  724. '
  725. Private Sub DisplayFile(Selection As MMCClipboard)
  726. On Error GoTo ErrTrap_DisplayFile
  727. Dim FileName As String
  728. Dim Path As String
  729. Dim ViewerForm As frmFileViewer
  730. ' If there is anything other than a single data object then we ignore it
  731. ' as FileExplorer exports one MMCDataObject with the format "File" when the
  732. ' selected item is a single file.
  733. If Selection.DataObjects.Count <> 1 Then
  734. Exit Sub
  735. End If
  736. ' If the "File" format is present then extract the name display our form
  737. ' with the contents of the file.
  738. If Not Selection.DataObjects(1).GetFormat("File") Then
  739. Exit Sub
  740. End If
  741. FileName = Selection.DataObjects(1).GetData("File")
  742. Path = Selection.DataObjects(1).GetData("Path")
  743. Set ViewerForm = New frmFileViewer
  744. ViewerForm.DisplayFile Path, FileName
  745. Unload ViewerForm
  746. Exit Sub
  747. ' Error Handler for this method
  748. ErrTrap_DisplayFile:
  749. DisplayError "DisplayFile"
  750. End Sub
  751. ' =============================================================================
  752. ' Method: DisplayError
  753. ' Type: Subroutine
  754. ' Description: A method to format and display a runtime error
  755. ' Parameters: szLocation A string identifying the source location
  756. ' (i.e. method name) where the error occurred
  757. ' Output: None
  758. ' Notes: The error will be displayed in a messagebox formatted as the
  759. ' following sample:
  760. '
  761. ' Method: SomeMethodName
  762. ' Source: MMCListSubItems
  763. ' Error: 2527h (9511)
  764. ' Description: There is already an item in the collection that has the specified key
  765. '
  766. ' =============================================================================
  767. '
  768. Private Sub DisplayError(szLocation As String)
  769. ' Note that as an extension snap-in we do not have access to the
  770. ' ConsoleMsgBox method so we need to use a VB message box.
  771. MsgBox "Method:" & vbTab & vbTab & szLocation & vbCrLf _
  772. & "Source:" & vbTab & vbTab & Err.Source & vbCrLf _
  773. & "Error:" & vbTab & vbTab & Hex(Err.Number) & "h (" & CStr(Err.Number) & ")" & vbCrLf _
  774. & "Description:" & vbTab & Err.Description, _
  775. vbCritical, "FileViewerExtension Runtime Error"
  776. End Sub