Einzelnen Beitrag anzeigen

msickel

Registriert seit: 14. Mai 2005
108 Beiträge
 
Delphi 2005 Professional
 
#1

VB nach delphi konvertieren

  Alt 10. Jan 2008, 13:03
Hallo, ich habe hier einen Visual Basic Code liegen und würde diesen gerne nach Delphi umschreiben, da ich aber von VB sogut wie keine Ahnung habe,
wollte ich mal fragen ob es ne gute Anleitung gibt mit der man das hinbekommt.

Ich poste mal den Quellcode von dem VB vielleicht kann sich das ja mal wer ansehen und mir entsprechende Tips geben.

Delphi-Quellcode:

Option Explicit


Implements TVClient.IAddIn

Private msURL As String
Private moApplication As Application ' Client application reference
Private moSession As Session
' Session reference from the client
Private mbAddPrimaryCommands As Boolean ' Should we add commands to the primary pane?
Private mbAddSecondaryCommands As Boolean
' Should we add commands to the secondary pane?
Private mlCommandID As Long ' Command ID we added and should respond to
Const lsKeyPath = "Software\AddIns\ReversePhoneLookUp"
'the registry path we will place any settings


Private Sub Class_Initialize()
    Dim oRegistry As RegistryAccess
    
    ' Default to not adding commands
mbAddPrimaryCommands = False
mbAddSecondaryCommands = False

'read the default URL from the registry if one has been saved
    Set oRegistry = New RegistryAccess
    msURL = oRegistry.GetRegSetting("URL", Key:=RegKeys.HKEY_LOCAL_MACHINE, SubKey:=lsKeyPath)
    'if a URL was not saved to the registry, set the default URL to do a Google search
If msURL = "" Then msURL = "http://www.google.com/search?q=<number>"
End Sub

Private Sub IAddIn_AddCommand(ByVal ExplorerKey As String, ByVal Pane As TVClient.Pane, ByVal Location As TVClient.CommandLocation, ByVal CommandNumber As Long, ByVal ID As Long, Caption As String, ToolTip As String, Picture As stdole.Picture, Enabled As Boolean, Checked As Boolean, AddAnotherCommand As Boolean, Shortcut As String)
'This method is fired for every menu click so it needs to be fast, hence it is referencing to global boolean variables instead of any object references like the client API
    ' If we should be adding commands then do so now
If ((Pane = PanePrimary And mbAddPrimaryCommands) Or (Pane = PaneSecondary And mbAddSecondaryCommands)) Then

' Make sure this is the context menu for a selected item
        If (Location = CommandLocationContextMenuOpen) Then
        
            ' Add a command to do the lookup
Caption = "Reverse Phone Number Lookup..."

'Set the icon for the command to the icon stored in the form
            Set Picture = frmOptions.Icon
            
            'This add in only has 1 command, so indicate there are no more commands to come
AddAnotherCommand = False

' Remember the command ID, which is a unique # for every command
            mlCommandID = ID
        End If
    End If
End Sub

Private Sub IAddIn_CommandClicked(ByVal ID As Long, ByVal SelectedID As String, ByVal SelectionCount As Long)
    Dim oItem As IItem
    Dim oCall As TeleVantage.Call
    Dim oContact As TeleVantage.Contact
    Dim oCallHistory As TeleVantage.CallHistory
    Dim oMessage As TeleVantage.Message
    Dim oAddress As TeleVantage.Address
    Dim sNumber As String

    On Error Resume Next

    ' Execute a lookup if this is our command ID. If this add-in supported multiple commands, then check them all here
If (ID = mlCommandID) Then

' Get the selected item
        Set oItem = moSession.GetItem(SelectedID)
        If Err <> 0 Then
            MsgBox "You must first select an item"
            Exit Sub
        End If
        ' Handle based on item type
Select Case (oItem.Class)
Case TVObjectClass.tvClassCall:
' a call
                ' Cast to the specific type
Set oCall = oItem

' Get the address
                Set oAddress = oCall.Address
                
                ' Get the number if there is a valid address
If Not (oAddress Is Nothing) Then sNumber = oAddress.Value

Case TVObjectClass.tvClassContact:
' a contact
                ' Cast to the specific type
Set oContact = oItem

' Get the default address
                Set oAddress = oContact.DefaultAddress
                
                ' Get the number if there is a valid address
If Not (oAddress Is Nothing) Then sNumber = oAddress.Value

Case TVObjectClass.tvClassCallHistory:
' a call log entry
                ' Cast to the specific type
Set oCallHistory = oItem

If oCallHistory.Direction = tvCallDirectionInbound Then
If the call was inbound, get the caller's address (the person that called me)
Set oAddress = oCallHistory.FromParty.CallerIDAddress
Else
If the call was outbound, get the callee's address (the person that I called)
Set oAddress = oCallHistory.ToParty.CallerIDAddress
End If

' Get the number if there is a valid address
                If Not (oAddress Is Nothing) Then sNumber = oAddress.Value
                
                
            Case TVObjectClass.tvClassMessage:
                ' a voice message or recording
' Cast to the specific type
                Set oMessage = oItem
                
                ' Get the default address
Set oAddress = oMessage.SenderCallerIDAddress

' Get the number if there is a valid address
                If Not (oAddress Is Nothing) Then sNumber = oAddress.Value
                  
                
        End Select
        'display the number using the URL specified, e.g. Google
Call DisplayURLWithEmbeddedPhoneNumber(msURL, sNumber)
End If
End Sub

Private Sub IAddIn_Disposed()
' Clear the object references
    Set moSession = Nothing
    Set moApplication = Nothing
End Sub

Private Sub IAddIn_Disposing(ByVal Reason As TVClient.DisposeReason, Cancel As Boolean)
    '
End Sub

Private Sub IAddIn_ExplorerResized(ByVal ExplorerKey As String)
'
End Sub

Private Sub IAddIn_FolderChanged(ByVal ExplorerKey As String, ByVal Pane As TVClient.Pane, ByVal FolderID As String)
'fired each time a folder is changed, in this event you should set up some variables to allow you to
'quickly add the right commands to the menus when IAddIn_AddCommand is executed

    Dim oFolder As TeleVantage.Folder
    Dim bThisFolderNeedsACommand As Boolean 'indicates if the active folder needs a Reverse Phone Number Look Up command

If there is no folder disable commands for the pane
    If (Len(FolderID) = 0) Then

        If (Pane = PanePrimary) Then
            mbAddPrimaryCommands = False
        ElseIf (Pane = PaneSecondary) Then
            mbAddSecondaryCommands = False
        End If
    
        Exit Sub
    End If
    
    ' Get the folder object for the new folder
Set oFolder = moSession.GetFolder(FolderID)

' Add this command only in the Contact, Call Monitor, Voice Message or Call Log views
    bThisFolderNeedsACommand = (oFolder.ItemClass = tvItemClassCallItem Or oFolder.ItemClass = tvItemClassContactItem Or oFolder.ItemClass = tvItemClassCallHistoryItem Or oFolder.ItemClass = tvItemClassMessageItem)
    If (Pane = PanePrimary) Then
        mbAddPrimaryCommands = bThisFolderNeedsACommand
    ElseIf (Pane = PaneSecondary) Then
        mbAddSecondaryCommands = bThisFolderNeedsACommand
    End If
    
    ' Get rid of the folder reference
Set oFolder = Nothing
End Sub

Private Function IAddIn_GetAddInInfo() As TVClient.AddInInfo
' Setup to return our own information
    With IAddIn_GetAddInInfo
        
        'using version 1 of the add-in interface
.AddInVersion = 1
.Author = "Vertical"
.Description = "Displays a web page (e.g. Google) to look up the phone number for a call, contact, voice message or call log entry. To use it, right click on an item and select
'Reverse Phone Number Lookup...'"

'display the Options button in the Client's add-in manager
.HasProperties = True
.Name = "Reverse Phone Number Lookup"

With .Version
'Set the add-in version information to the version info of this component
            .Major = App.Major
            .Minor = App.Minor
            .Build = App.Revision
        End With
    End With
End Function

Private Sub IAddIn_Initialize(ByVal Application As TVClient.Application, ByVal Session As TeleVantage.Session)
    ' Store the object references
Set moApplication = Application
Set moSession = Session
End Sub

Private Sub IAddIn_SelectionChanged(ByVal ExplorerKey As String, ByVal Pane As TVClient.Pane, ByVal SelectedID As String, ByVal SelectionCount As Long)
'
End Sub

Private Sub IAddIn_ShowProperties()
    Dim sURL As String
    Dim oRegistry As RegistryAccess
    Dim retVal As Long
    
 
    'Get a copy of the current URL
sURL = msURL

' Show the options dialog and store the new URL if okay was clicked
    If (frmOptions.Display(sURL)) Then
        msURL = sURL
        'save the new URL in the registry
Set oRegistry = New RegistryAccess
retVal = oRegistry.SetRegSetting("URL", msURL, Key:=RegKeys.HKEY_LOCAL_MACHINE, SubKey:=lsKeyPath)
End If


' Clear the form
    Set frmOptions = Nothing
End Sub

bin für jede Hilfe dankbar.

Martin
ich weiss, das ich nichts weiss!
  Mit Zitat antworten Zitat