AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

VB nach delphi konvertieren

Ein Thema von msickel · begonnen am 10. Jan 2008 · letzter Beitrag vom 10. Jan 2008
Antwort Antwort
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
shmia

Registriert seit: 2. Mär 2004
5.508 Beiträge
 
Delphi 5 Professional
 
#2

Re: VB nach delphi konvertieren

  Alt 10. Jan 2008, 13:41
Im vorliegenden Code wird ein bestimmtes Interface namens IAddIn implementiert.

Um das Gleiche in Delphi zu tun, musst du zuerst die richtige TLB importieren.
(über Projekt->Typbibliothek importieren...)
In dem von Delphi generierte Code muss dann das Interface IAddIn zu finden sein.
Andreas
  Mit Zitat antworten Zitat
jogging_cat

Registriert seit: 2. Nov 2007
Ort: Langewiesen
14 Beiträge
 
Delphi 5 Enterprise
 
#3

Re: VB nach delphi konvertieren

  Alt 10. Jan 2008, 13:56
Hallo,

Implements TVClient.IAddIn Das ist so was wie eine UNIT in Delphi. Nur hier wohl in .NET.
Wenn es so was in Delphi nicht gibt, dann Ende.
Aber es gibt doch auch Delphi für .NET.

Private Sub Class_Initialize() ist so was wie der Konstruktor.

Dim oRegistry As RegistryAccess ist eine Variablendefinition eines Objektes (Instanz), das wohl in einer UNIT in VB
deklariert ist. Es muss nicht TVClient.IAddIn sein, da es um Registry geht kann es auch
System sein. Und die ist immer vorhanden.

Private Sub IAddIn_AddCommand ist wohl eine Funktion von TVClient.IAddIn. Wohl aus dem Menü?

Private Sub IAddIn_CommandClicked ist eine Ereignisroutine. Ähnlich wie Button_Click.

Private Sub IAddIn_Disposed() sieht aus wie der Destruktor.

Private Sub IAddIn_FolderChanged ist die Ereignisroutine zum Ändern von ... ?

Private Sub IAddIn_Initialize ist der Aufruf des Konstruktor einer Klasse von TVClient.IAddIn.

Private Sub IAddIn_SelectionChanged ist die Ereignisroutine für ?? - sieht aus wie Auswahl aus Listenfeld.

Grüße jogging_cat
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#4

Re: VB nach delphi konvertieren

  Alt 10. Jan 2008, 15:17
Da ich einiges etwa 15 Jahre Erfahrung in VB habe
rate ich dir trotzdem davon ab den Quelltext übersetzen zu wollen.

Habe hier als ich mit Delphi angefangen habe schmerzliche erinnerungen davon tragen müssen
vorallem wenn es darum geht subclassing von VB nach Delphi zu übersetzen.

Das einzigste was dir übrigbleibt aus den Quelltext anregungen zu übernehmen.
Das übersetzen fällt auf jedenfall negativ aus bis auf einige parts.

Was du hier übersetzen willst in ein Interface von VB was weder in C noch in Delphi
so ohne weiteres benutzt werden kann.

Gerade mit Com hat Delphi so seine Problem..

gruss Emil

PS: Wenn es dir um fernsehen geht habe gerade einen Wrapper für Winamp TV fertig gestellt
bei interesse kann ich die DLL und ein Sample in VB mal hier hochladen.
Was noch fehlt ist die Interface.pas zur Ansteuerung der DLl (noch keine zeit)
Scheint aber eher weniger damit zu tun haben .. (TVClient) ist wohl eine zusätzlich eingebunden DLL
in diesen Projekt.
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#5

Re: VB nach delphi konvertieren

  Alt 10. Jan 2008, 15:21
Zitat:
Was du hier übersetzen willst in ein Interface von VB was weder in C noch in Delphi
so ohne weiteres benutzt werden kann.
Das liegt dann aber eher an VB
Markus Kinzler
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#6

Re: VB nach delphi konvertieren

  Alt 10. Jan 2008, 15:23
Zitat von mkinzler:
Zitat:
Was du hier übersetzen willst in ein Interface von VB was weder in C noch in Delphi
so ohne weiteres benutzt werden kann.
Das liegt dann aber eher an VB
Streite ich nicht ab


Zitat:
Das ist so was wie eine UNIT in Delphi. Nur hier wohl in .NET.
Wenn es so was in Delphi nicht gibt, dann Ende.
Aber es gibt doch auch Delphi für .NET.
nö.. Das ist entweder eine eingebundene Schnittstelle als (ActiveX)DLL
oder eine im Projekt enthaltene cTClient.cls (Klasse)
Du mußt also nicht nur den Quelltext übersetzen sondern die DLL über Typelib zusätzlich mit einbinden..

Ach vergeß es einfach

gruss Emil
  Mit Zitat antworten Zitat
msickel

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

Re: VB nach delphi konvertieren

  Alt 10. Jan 2008, 19:46
Zitat von EWeiss:

Ach vergeß es einfach

gruss Emil
möchte ich eigentlich nicht, ein Versuch ist es Wert

Aber ich würde Dich ab und an (ehr öfters) um Rat Fragen wenn es ok ist.

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

Registriert seit: 15. Nov 2003
Ort: Berlin
934 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#8

Re: VB nach delphi konvertieren

  Alt 10. Jan 2008, 20:04
Hi,

was bzw. woher stammt den der Code?

Sieht eher aus wie eine Videokonferenz-Software(wenn Google das gefunden hat, was es ist?).

Ansonsten wie bereits geschrieben wurde Tyblib einbinden und dann über Interface programmieren.

Gruß
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:40 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz