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.

300 lines
7.9 KiB

  1. VERSION 5.00
  2. Begin VB.Form frmMain
  3. Caption = "PrepareHHCsForLoc"
  4. ClientHeight = 5430
  5. ClientLeft = 270
  6. ClientTop = 450
  7. ClientWidth = 9390
  8. LinkTopic = "Form1"
  9. ScaleHeight = 5430
  10. ScaleWidth = 9390
  11. StartUpPosition = 3 'Windows Default
  12. Begin VB.CheckBox chkRecurse
  13. Caption = "&Recurse through sub folders"
  14. Height = 255
  15. Left = 120
  16. TabIndex = 3
  17. Top = 480
  18. Width = 2415
  19. End
  20. Begin VB.TextBox txtOutput
  21. Height = 4335
  22. Left = 120
  23. MultiLine = -1 'True
  24. ScrollBars = 3 'Both
  25. TabIndex = 6
  26. Top = 960
  27. Width = 9135
  28. End
  29. Begin VB.CommandButton cmdClose
  30. Caption = "Close"
  31. Height = 375
  32. Left = 8400
  33. TabIndex = 5
  34. Top = 480
  35. Width = 855
  36. End
  37. Begin VB.CommandButton cmdFolder
  38. Caption = "..."
  39. Height = 255
  40. Left = 8880
  41. TabIndex = 2
  42. Top = 120
  43. Width = 375
  44. End
  45. Begin VB.CommandButton cmdGo
  46. Caption = "Go"
  47. Height = 375
  48. Left = 7440
  49. TabIndex = 4
  50. Top = 480
  51. Width = 855
  52. End
  53. Begin VB.TextBox txtFolder
  54. Height = 285
  55. Left = 720
  56. TabIndex = 1
  57. Top = 120
  58. Width = 8055
  59. End
  60. Begin VB.Label lbl
  61. Caption = "&Folder"
  62. Height = 255
  63. Left = 120
  64. TabIndex = 0
  65. Top = 120
  66. Width = 495
  67. End
  68. End
  69. Attribute VB_Name = "frmMain"
  70. Attribute VB_GlobalNameSpace = False
  71. Attribute VB_Creatable = False
  72. Attribute VB_PredeclaredId = True
  73. Attribute VB_Exposed = False
  74. Option Explicit
  75. ' Make sure that these letters correspond to the Alt key combinations.
  76. Private Const OPT_FOLDER_C As String = "f"
  77. Private Const OPT_RECURSE_C As String = "r"
  78. Private Const OPT_LOG_FILE_C As String = "l"
  79. Private Const OPT_CLOSE_ON_WARNING_C As String = "qw"
  80. Private Const OPT_CLOSE_ALWAYS_C As String = "qa"
  81. Private Const OPT_HELP_C As String = "h,?,help"
  82. Private p_strSeparator As String
  83. Private p_blnWarning As Boolean
  84. Private p_blnError As Boolean
  85. Private p_clsSizer As Sizer
  86. Private WithEvents p_frmFolderChooser As frmFolderChooser
  87. Attribute p_frmFolderChooser.VB_VarHelpID = -1
  88. Private Sub p_DisplayHelp()
  89. Dim str As String
  90. str = "Usage: " & vbCrLf & vbCrLf & _
  91. App.EXEName & " /f <Folder> /r /l <Log File> /qw /qa" & vbCrLf & vbCrLf & _
  92. "The /r, /l, /qw, and /qa arguments are optional." & vbCrLf & _
  93. "/r causes the application to recurse through sub folders." & vbCrLf & _
  94. "/qw makes the window go away even if there are Warnings." & vbCrLf & _
  95. "/qa makes the window go away even if there are Errors and/or Warnings." & vbCrLf & _
  96. """" & App.EXEName & " /?"" displays this message."
  97. Output str, LOGGING_TYPE_NORMAL_E
  98. Output p_strSeparator, LOGGING_TYPE_NORMAL_E
  99. End Sub
  100. Private Sub Form_Load()
  101. Dim strLogFile As String
  102. cmdGo.Default = True
  103. cmdClose.Cancel = True
  104. Set p_clsSizer = New Sizer
  105. Set p_frmFolderChooser = New frmFolderChooser
  106. strLogFile = GetOption(Command$, OPT_LOG_FILE_C, True)
  107. SetLogFile strLogFile
  108. Output "Version " & App.Major & "." & App.Minor & "." & App.Revision, LOGGING_TYPE_NORMAL_E
  109. p_strSeparator = String(80, "-")
  110. Output p_strSeparator, LOGGING_TYPE_NORMAL_E
  111. p_ProcessCommandLine
  112. End Sub
  113. Private Sub p_ProcessCommandLine()
  114. Dim strCommand As String
  115. Dim blnCloseOnWarning As Boolean
  116. Dim blnCloseAlways As Boolean
  117. Dim blnClose As Boolean
  118. strCommand = Trim$(Command$)
  119. If (strCommand = "") Then
  120. Exit Sub
  121. End If
  122. txtFolder = GetOption(strCommand, OPT_FOLDER_C, True)
  123. If (OptionExists(strCommand, OPT_RECURSE_C, True)) Then
  124. chkRecurse.Value = vbChecked
  125. End If
  126. blnCloseOnWarning = OptionExists(strCommand, OPT_CLOSE_ON_WARNING_C, True)
  127. blnCloseAlways = OptionExists(strCommand, OPT_CLOSE_ALWAYS_C, True)
  128. If (OptionExists(strCommand, OPT_HELP_C, True)) Then
  129. p_DisplayHelp
  130. ElseIf (Len(strCommand) <> 0) Then
  131. cmdGo_Click
  132. If (p_blnError) Then
  133. ' If an error occurred, then close the window only if OPT_CLOSE_ALWAYS_C is specified.
  134. If (blnCloseAlways) Then
  135. blnClose = True
  136. End If
  137. ElseIf (p_blnWarning) Then
  138. ' If a warning occurred, but there was no error, then close the window only if
  139. ' OPT_CLOSE_ON_WARNING_C or OPT_CLOSE_ALWAYS_C is specified.
  140. If (blnCloseOnWarning Or blnCloseAlways) Then
  141. blnClose = True
  142. End If
  143. Else
  144. ' If there was no warning or error, then close the window.
  145. blnClose = True
  146. End If
  147. If (blnClose) Then
  148. cmdClose_Click
  149. End If
  150. End If
  151. End Sub
  152. Private Sub cmdGo_Click()
  153. On Error GoTo LError
  154. Dim strFolder As String
  155. Dim blnRecurse As Boolean
  156. Output "Start: " & Date & " " & Time, LOGGING_TYPE_NORMAL_E
  157. strFolder = Trim$(txtFolder.Text)
  158. If (strFolder = "") Then
  159. Output "Please specify the Folder", LOGGING_TYPE_ERROR_E
  160. GoTo LError
  161. End If
  162. If (chkRecurse.Value = vbChecked) Then
  163. blnRecurse = True
  164. End If
  165. Me.Enabled = False
  166. MainFunction strFolder, blnRecurse
  167. LEnd:
  168. Output "End: " & Date & " " & Time, LOGGING_TYPE_NORMAL_E
  169. Output "The log file is: " & GetLogFileName, LOGGING_TYPE_NORMAL_E
  170. Output p_strSeparator, LOGGING_TYPE_NORMAL_E
  171. Me.Enabled = True
  172. Exit Sub
  173. LError:
  174. GoTo LEnd
  175. End Sub
  176. Private Sub cmdClose_Click()
  177. Unload Me
  178. End Sub
  179. Private Sub cmdFolder_Click()
  180. Load p_frmFolderChooser
  181. p_frmFolderChooser.SetFolder 0, txtFolder.Text
  182. p_frmFolderChooser.Show vbModal
  183. End Sub
  184. Private Sub p_frmFolderChooser_FolderChosen( _
  185. ByVal i_intIndex As Long, _
  186. ByVal strFolder As String _
  187. )
  188. txtFolder.Text = strFolder
  189. End Sub
  190. Private Sub Form_Activate()
  191. On Error GoTo LError
  192. p_SetSizingInfo
  193. DoEvents
  194. LError:
  195. End Sub
  196. Private Sub Form_Resize()
  197. On Error GoTo LError
  198. p_clsSizer.Resize
  199. LError:
  200. End Sub
  201. Private Sub p_SetSizingInfo()
  202. Dim intIndex As Long
  203. p_clsSizer.AddControl txtFolder
  204. Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = Me
  205. p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E
  206. p_clsSizer.AddControl cmdGo
  207. Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me
  208. p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
  209. p_clsSizer.AddControl cmdClose
  210. Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me
  211. p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
  212. p_clsSizer.AddControl txtOutput
  213. Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = Me
  214. p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E
  215. Set p_clsSizer.ReferenceControl(DIM_BOTTOM_E) = Me
  216. p_clsSizer.ReferenceDimension(DIM_BOTTOM_E) = DIM_HEIGHT_E
  217. End Sub
  218. Public Sub Output( _
  219. ByVal i_str As String, _
  220. ByVal i_enumLoggingType As LOGGING_TYPE_E _
  221. )
  222. OutputToTextBoxAndWriteLog txtOutput, i_str, i_enumLoggingType
  223. If (i_enumLoggingType = LOGGING_TYPE_ERROR_E) Then
  224. p_blnError = True
  225. ElseIf (i_enumLoggingType = LOGGING_TYPE_WARNING_E) Then
  226. p_blnWarning = True
  227. End If
  228. End Sub