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.

117 lines
4.3 KiB

  1. VERSION 5.00
  2. Begin VB.UserControl ctlFileViewer
  3. ClientHeight = 3600
  4. ClientLeft = 0
  5. ClientTop = 0
  6. ClientWidth = 4800
  7. ScaleHeight = 3600
  8. ScaleWidth = 4800
  9. Begin VB.TextBox txtFile
  10. BackColor = &H8000000F&
  11. Height = 2775
  12. Left = 113
  13. MultiLine = -1 'True
  14. ScrollBars = 3 'Both
  15. TabIndex = 0
  16. Text = "FileViewerCtl.ctx":0000
  17. Top = 600
  18. Width = 4575
  19. End
  20. Begin VB.Label Label1
  21. Caption = "File:"
  22. Height = 255
  23. Left = 113
  24. TabIndex = 2
  25. Top = 0
  26. Width = 735
  27. End
  28. Begin VB.Label lblFileName
  29. Caption = "File name goes here at runtime"
  30. Height = 255
  31. Left = 1193
  32. TabIndex = 1
  33. Top = 0
  34. Width = 3495
  35. End
  36. End
  37. Attribute VB_Name = "ctlFileViewer"
  38. Attribute VB_GlobalNameSpace = False
  39. Attribute VB_Creatable = True
  40. Attribute VB_PredeclaredId = False
  41. Attribute VB_Exposed = True
  42. Option Explicit
  43. ' ===========================================================================
  44. ' | THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF |
  45. ' | ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO |
  46. ' | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A |
  47. ' | PARTICULAR PURPOSE. |
  48. ' | Copyright (c) 1998-1999 Microsoft Corporation |
  49. ' ===========================================================================
  50. ' =============================================================================
  51. ' File: FileViewerCtl.ctl
  52. ' Project: FileViewerExtensionProj
  53. ' Type: User Control
  54. ' =============================================================================
  55. ' =============================================================================
  56. ' Method: DisplayFile
  57. ' Type: Public Method
  58. ' Description: Called by either the file viewer form or property page to
  59. ' display the contents of the file.
  60. '
  61. ' Parameters: Path Fully qualified path of file to display
  62. ' Name Name of file to display
  63. ' Output: None
  64. ' Notes: Uses the FileSystemObject to read the contents of the file
  65. ' into a multi-line edit control.
  66. ' =============================================================================
  67. '
  68. Public Sub DisplayFile(Path As String, FileName As String)
  69. On Error GoTo ErrTrap_DisplayFile
  70. Dim fs As New Scripting.FileSystemObject
  71. Dim ts As TextStream
  72. lblFileName.Caption = FileName
  73. Set ts = fs.OpenTextFile(Path, ForReading, TristateUseDefault)
  74. txtFile.Text = ts.ReadAll
  75. ts.Close
  76. Exit Sub
  77. ' Error Handler for this method
  78. ErrTrap_DisplayFile:
  79. DisplayError "DisplayFile"
  80. End Sub
  81. ' =============================================================================
  82. ' Method: DisplayError
  83. ' Type: Subroutine
  84. ' Description: A method to format and display a runtime error
  85. ' Parameters: szLocation A string identifying the source location
  86. ' (i.e. method name) where the error occurred
  87. ' Output: None
  88. ' Notes: The error will be displayed in a messagebox formatted as the
  89. ' following sample:
  90. '
  91. ' Method: SomeMethodName
  92. ' Source: MMCListSubItems
  93. ' Error: 2527h (9511)
  94. ' Description: There is already an item in the collection that has the specified key
  95. '
  96. ' =============================================================================
  97. '
  98. Private Sub DisplayError(szLocation As String)
  99. MsgBox "Method:" & vbTab & vbTab & szLocation & vbCrLf _
  100. & "Source:" & vbTab & vbTab & Err.Source & vbCrLf _
  101. & "Error:" & vbTab & vbTab & Hex(Err.Number) & "h (" & CStr(Err.Number) & ")" & vbCrLf _
  102. & "Description:" & vbTab & Err.Description, _
  103. vbCritical, "FileViewerExtension Runtime Error"
  104. End Sub