home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Ulli's_Sou573102242002.psc / dCompare.Dsr (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2002-02-25  |  8.1 KB  |  174 lines

  1. VERSION 5.00
  2. Begin {AC0714F6-3D04-11D1-AE7D-00A0C90F26F4} dCompare 
  3.    ClientHeight    =   10005
  4.    ClientLeft      =   1740
  5.    ClientTop       =   1545
  6.    ClientWidth     =   11805
  7.    _ExtentX        =   20823
  8.    _ExtentY        =   17648
  9.    _Version        =   393216
  10.    Description     =   "Ulli's VB Source Code Comparator"
  11.    DisplayName     =   "Ulli's VB Source Code Comparator"
  12.    AppName         =   "Visual Basic"
  13.    AppVer          =   "Visual Basic 6.0"
  14.    LoadName        =   "Startup"
  15.    LoadBehavior    =   1
  16.    RegLocation     =   "HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0"
  17.    CmdLineSupport  =   -1  'True
  18. Attribute VB_Name = "dCompare"
  19. Attribute VB_GlobalNameSpace = False
  20. Attribute VB_Creatable = True
  21. Attribute VB_PredeclaredId = False
  22. Attribute VB_Exposed = True
  23. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  24.  2002     UMGEDV GmbH  (umgedv@aol.com)
  25. 'Author     UMG (Ulli K. Muehlenweg)
  26. 'Title      VB6 Source File Comparator Add-In
  27. 'Purpose    This AddIn lets compare the current state of your source in the IDE
  28. '           with the source as stored in the corresponding source-file.
  29. '           Compile the DLL into your VB directory and then use the Add-Ins
  30. '           Manager to load the Comparator Add-In into VB.
  31. '*********************************************************************************
  32. 'Development History
  33. '*********************************************************************************
  34. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  35. '24 Feb 2002 Version 1.1.4      UMG
  36. 'Tidy source
  37. 'Changed scan thru Sigs to make sure that a signature is found and not something
  38. 'in between. This could happen if the tail of one sig and the head of the next
  39. 'by coincidence combine to be legal.
  40. 'Changed 2nd and 3rd param for GetTempFileName
  41. 'Added check for new file (no old file to compare it with)
  42. 'Added progress indication
  43. 'Added tool tips and save option
  44. 'Removed MsgHook, is not needed any more.
  45. 'Removed position sensitivity; a line which is only shifted (indented) is considered
  46. 'equal to the non-shifted line. Changes to the source by the Code Formatter are thus
  47. 'suppressed.
  48. 'Now outputs new line for unaltered lines to reflect the most recent state for
  49. 'shifted lines.
  50. 'Fixed bug with saving and restoring (.frx files for example)
  51. 'Known quirk: For no evident reason VB seems to alter .frx files occasionally, so
  52. '             the AddIn may show changes in connection with this where in fact there
  53. '             are none.
  54. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  55. '22 Feb 2002 Version 1.0.7      Prototype - UMG
  56. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  57. Option Explicit
  58. DefLng A-Z 'we're 32 bit
  59. Private Const MenuName          As String = "Add-Ins" 'you may need to localize "Add-Ins"
  60. Private Const Backslash         As String = "\"
  61. Attribute Backslash.VB_VarDescription = "A single backslash"
  62. Private Const SleepTime         As Long = 999
  63. Attribute SleepTime.VB_VarDescription = "Time to show the Splash Form"
  64. Private VBInstance              As VBIDE.VBE
  65. Private CommandBarMenu          As CommandBar
  66. Private MenuItem                As CommandBarControl
  67. Private WithEvents MenuEvents   As CommandBarEvents
  68. Attribute MenuEvents.VB_VarHelpID = -1
  69. Private OrigFilenames()         As String
  70. Private TempFilenames()         As String
  71. Private IsDirty                 As Boolean
  72. Private i                       As Long
  73. Private CaptText                As String
  74. Private Sub AddinInstance_OnBeginShutdown(custom() As Variant)
  75.     If Not fCompare Is Nothing Then
  76.         fCompare.WindowState = vbMinimized
  77.         DoEvents
  78.         Unload fCompare
  79.     End If
  80. End Sub
  81. Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
  82.   Dim ClipboardText As String
  83.     Set VBInstance = Application
  84.     If ConnectMode = ext_cm_External Then
  85.         CompareSources
  86.       Else 'NOT CONNECTMODE...
  87.         On Error Resume Next
  88.           Set CommandBarMenu = VBInstance.CommandBars(MenuName)
  89.         On Error GoTo 0
  90.         If CommandBarMenu Is Nothing Then
  91.             MsgBox "VB Source Comaparator was loaded but could not be connected to the " & MenuName & " menu.", vbCritical
  92.           Else 'NOT COMMANDBARMENU...
  93.             fSplash.Show
  94.             DoEvents
  95.             With CommandBarMenu
  96.                 Set MenuItem = .Controls.Add(msoControlButton)
  97.                 i = .Controls.Count - 1
  98.                 If .Controls(i).BeginGroup And Not .Controls(i - 1).BeginGroup Then
  99.                     'menu separator required
  100.                     MenuItem.BeginGroup = True
  101.                 End If
  102.             End With 'COMMANDBARMENU
  103.             'set menu caption
  104.             With App
  105.                 MenuItem.Caption = "&" & .ProductName & " V" & .Major & "." & .Minor & "." & .Revision & "..."
  106.             End With 'APP
  107.             With Clipboard
  108.                 ClipboardText = .GetText
  109.                 'set menu picture
  110.                 .SetData fSplash.picMenu.Image
  111.                 MenuItem.PasteFace
  112.                 .Clear
  113.                 .SetText ClipboardText
  114.             End With 'CLIPBOARD
  115.             'set event handler
  116.             Set MenuEvents = VBInstance.Events.CommandBarEvents(MenuItem)
  117.             'done connecting
  118.             Sleep SleepTime
  119.             Unload fSplash
  120.         End If
  121.     End If
  122. End Sub
  123. Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
  124.     On Error Resume Next
  125.       MenuItem.Delete
  126.     On Error GoTo 0
  127. End Sub
  128. Public Sub CompareSources()
  129. Attribute CompareSources.VB_Description = "The main Sub"
  130. Attribute CompareSources.VB_UserMemId = 0
  131.   Dim fc As Long
  132.     If VBInstance.CodePanes.Count Then
  133.         CaptText = App.ProductName & " - " & VBInstance.ActiveVBProject.Name & " [" & VBInstance.SelectedVBComponent.Name & "]"
  134.         With VBInstance.SelectedVBComponent
  135.             If Len(.FileNames(1)) = 0 Then
  136.                 MsgBox "This file is new; there is no old file to compare it with.", vbInformation, CaptText
  137.               Else 'NOT LEN(.FILENAMES(1))...
  138.                 If MsgBox("Do you want to compare this Source File?", vbQuestion + vbOKCancel, CaptText) = vbOK Then
  139.                     IsDirty = .IsDirty
  140.                               
  141.                     fCompare.Caption = CaptText
  142.                     
  143.                     fc = .FileCount
  144.                     ReDim OrigFilenames(1 To fc), TempFilenames(1 To fc)
  145.                     For i = 1 To fc
  146.                         OrigFilenames(i) = .FileNames(i)
  147.                         TempFilenames(i) = String$(255, 0)
  148.                         GetTempFileName Left$(OrigFilenames(i), InStrRev(OrigFilenames(i), Backslash)), "UMG", 0, TempFilenames(i)
  149.                         TempFilenames(i) = Left$(TempFilenames(i), InStr(TempFilenames(i), Chr$(0)) - 1)
  150.                         FileCopy OrigFilenames(i), TempFilenames(i)
  151.                     Next i
  152.                     
  153.                     .SaveAs OrigFilenames(1) 'may alter the .frx file
  154.                     fCompare.Compare TempFilenames(1), OrigFilenames(1)
  155.                     .IsDirty = IsDirty
  156.                     
  157.                     For i = 1 To fc
  158.                         FileCopy TempFilenames(i), OrigFilenames(i)
  159.                         Kill TempFilenames(i)
  160.                     Next i
  161.                                     
  162.                 End If
  163.             End If
  164.         End With 'VBINSTANCE.SELECTEDVBCOMPONENT
  165.       Else 'VBINSTANCE.CODEPANES.COUNT = FALSE
  166.         MsgBox "Cannot see any Code - you must open a Code Panel first.", vbExclamation, "Ulli's VB Code Comparator"
  167.     End If
  168.         
  169. End Sub
  170. Private Sub MenuEvents_Click(ByVal CommandBarControl As Object, handled As Boolean, CancelDefault As Boolean)
  171.     CompareSources
  172. End Sub
  173. ':) Ulli's VB Code Formatter V2.10.7 (24.02.2002 22:14:11) 68 + 115 = 183 Lines
  174.