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.

240 lines
6.3 KiB

  1. '//+----------------------------------------------------------------------------
  2. '//
  3. '// File: copypb.frm
  4. '//
  5. '// Module: pbadmin.exe
  6. '//
  7. '// Synopsis: The dialog to copy a phonebook
  8. '//
  9. '// Copyright (c) 1997-1999 Microsoft Corporation
  10. '//
  11. '// Author: quintinb Created Header 09/02/99
  12. '//
  13. '//+----------------------------------------------------------------------------
  14. VERSION 5.00
  15. Begin VB.Form frmCopyPB
  16. BorderStyle = 3 'Fixed Dialog
  17. ClientHeight = 2895
  18. ClientLeft = 3675
  19. ClientTop = 1620
  20. ClientWidth = 3285
  21. Icon = "copyPB.frx":0000
  22. KeyPreview = -1 'True
  23. LinkTopic = "Form1"
  24. MaxButton = 0 'False
  25. MinButton = 0 'False
  26. PaletteMode = 1 'UseZOrder
  27. ScaleHeight = 2895
  28. ScaleWidth = 3285
  29. ShowInTaskbar = 0 'False
  30. WhatsThisButton = -1 'True
  31. WhatsThisHelp = -1 'True
  32. Begin VB.TextBox NewPBText
  33. Height = 315
  34. Left = 405
  35. MaxLength = 8
  36. TabIndex = 1
  37. Top = 1995
  38. WhatsThisHelpID = 13020
  39. Width = 2250
  40. End
  41. Begin VB.CommandButton cmbCancel
  42. Cancel = -1 'True
  43. Caption = "cancel"
  44. Height = 375
  45. Left = 1635
  46. TabIndex = 3
  47. Top = 2415
  48. WhatsThisHelpID = 10040
  49. Width = 1005
  50. End
  51. Begin VB.CommandButton cmbOK
  52. Caption = "ok"
  53. Default = -1 'True
  54. Enabled = 0 'False
  55. Height = 375
  56. Left = 420
  57. TabIndex = 2
  58. Top = 2415
  59. WhatsThisHelpID = 10030
  60. Width = 1065
  61. End
  62. Begin VB.Label OriginalPBLabel
  63. BackStyle = 0 'Transparent
  64. BorderStyle = 1 'Fixed Single
  65. Height = 285
  66. Left = 390
  67. TabIndex = 6
  68. Top = 1440
  69. WhatsThisHelpID = 13010
  70. Width = 2250
  71. End
  72. Begin VB.Label OrigLabel
  73. BackStyle = 0 'Transparent
  74. Caption = "orig"
  75. Height = 240
  76. Left = 405
  77. TabIndex = 5
  78. Top = 1215
  79. WhatsThisHelpID = 13010
  80. Width = 2385
  81. End
  82. Begin VB.Label NewLabel
  83. BackStyle = 0 'Transparent
  84. Caption = "new"
  85. Height = 240
  86. Left = 420
  87. TabIndex = 0
  88. Top = 1755
  89. WhatsThisHelpID = 13020
  90. Width = 2340
  91. End
  92. Begin VB.Label DescLabel
  93. BackStyle = 0 'Transparent
  94. Caption = "enter a new ..."
  95. Height = 930
  96. Left = 90
  97. TabIndex = 4
  98. Top = 105
  99. Width = 2955
  100. End
  101. End
  102. Attribute VB_Name = "frmCopyPB"
  103. Attribute VB_GlobalNameSpace = False
  104. Attribute VB_Creatable = False
  105. Attribute VB_PredeclaredId = True
  106. Attribute VB_Exposed = False
  107. Option Explicit
  108. Public strPB As String
  109. Function LoadCopyRes()
  110. On Error GoTo LoadErr
  111. Me.Caption = LoadResString(4070)
  112. DescLabel.Caption = LoadResString(4068)
  113. OrigLabel.Caption = LoadResString(4071)
  114. NewLabel.Caption = LoadResString(4069)
  115. cmbOK.Caption = LoadResString(1002)
  116. cmbCancel.Caption = LoadResString(1003)
  117. ' set fonts
  118. SetFonts Me
  119. On Error GoTo 0
  120. Exit Function
  121. LoadErr:
  122. Exit Function
  123. End Function
  124. Private Sub cmbCancel_Click()
  125. Me.Hide
  126. End Sub
  127. Private Sub cmbOK_Click()
  128. ' mainly make sure that they've entered
  129. ' a unique pb name and then just do it.
  130. Dim strNewPB, strOrigPB As String
  131. Dim varRegKeys As Variant
  132. Dim intX As Integer
  133. Dim rsNewPB As Recordset
  134. Dim dblFreeSpace As Double
  135. On Error GoTo ErrTrap
  136. Screen.MousePointer = 11
  137. dblFreeSpace = GetDriveSpace(locPath, filelen(gsCurrentPBPath) + 10000)
  138. If dblFreeSpace = -2 Then
  139. Screen.MousePointer = 0
  140. Exit Sub
  141. End If
  142. strNewPB = Trim(NewPBText.Text)
  143. strOrigPB = Trim(OriginalPBLabel.Caption)
  144. If TestNewPBName(strNewPB) = 0 Then
  145. 'ok
  146. Me.Enabled = False
  147. DBEngine.Idle
  148. GsysPb.Close
  149. Set GsysPb = Nothing
  150. MakeFullINF strNewPB
  151. MakeLogFile strNewPB
  152. FileCopy locPath & strOrigPB & ".mdb", locPath & strNewPB & ".mdb"
  153. OSWritePrivateProfileString "Phonebooks", strNewPB, strNewPB & ".mdb", locPath & gsRegAppTitle & ".ini"
  154. OSWritePrivateProfileString vbNullString, vbNullString, vbNullString, locPath & gsRegAppTitle & ".ini"
  155. 'edit the mdb - options
  156. frmMain.SetCurrentPB strNewPB
  157. Set rsNewPB = GsysPb.OpenRecordset("Configuration")
  158. DBEngine.Idle
  159. rsNewPB.MoveLast
  160. rsNewPB.Edit
  161. rsNewPB!ServiceName = strNewPB
  162. rsNewPB.Update
  163. GsysPb.Execute "UPDATE Delta set DeltaNum = 1 where DeltaNum <> 1", dbFailOnError
  164. GsysPb.Execute "UPDATE Delta set NewVersion = 0", dbFailOnError
  165. GsysPb.Execute "DELETE * from PhoneBookVersions", dbFailOnError
  166. DBEngine.Idle
  167. rsNewPB.Close
  168. Set rsNewPB = Nothing
  169. strPB = strNewPB
  170. Me.Enabled = True
  171. Me.Hide
  172. Else
  173. NewPBText.SetFocus
  174. NewPBText.SelStart = 0
  175. NewPBText.SelLength = Len(NewPBText.Text)
  176. End If
  177. Screen.MousePointer = 0
  178. Exit Sub
  179. ErrTrap:
  180. Screen.MousePointer = 0
  181. Me.Enabled = True
  182. Exit Sub
  183. End Sub
  184. Private Sub Form_KeyPress(KeyAscii As Integer)
  185. CheckChar KeyAscii
  186. End Sub
  187. Private Sub Form_Load()
  188. strPB = ""
  189. OriginalPBLabel.Caption = " " & gsCurrentPB
  190. CenterForm Me, Screen
  191. LoadCopyRes
  192. End Sub
  193. Private Sub NewPBText_Change()
  194. If Trim$(NewPBText.Text) <> "" Then
  195. cmbOK.Enabled = True
  196. Else
  197. cmbOK.Enabled = False
  198. End If
  199. End Sub
  200. Private Sub NewPBText_KeyPress(KeyAscii As Integer)
  201. KeyAscii = FilterPBKey(KeyAscii, NewPBText)
  202. End Sub