Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   VB to Delphi bräuchte Unterstützung (https://www.delphipraxis.net/159076-vbulletin-delphi-braeuchte-unterstuetzung.html)

msickel 13. Mär 2011 14:10

VB to Delphi bräuchte Unterstützung
 
Hallo ihr lieben Spezialisten :-)

Ich versuche diesen VB Quelltext nach Delphi zu Übersetzen.

Delphi-Quellcode:
’ This sample code changes Personal Status to "In a Meeting"
Private WithEvents oSession As Session
Private Sub Command1_Click()
’ Session and User object variables
Dim oSession As New Session
Dim oUser As User
’ Variables to hold the collection of Personal Status objects for user
Dim oPersonalStatusFolder As Folder
Dim oPersonalStatus As TeleVantage.PersonalStatus
’ Log on to the TeleVantage Server.
’ “32402” is a unique number used to identify the application using this Session object.
    oSession.Logon "Server_Name", "Joe Smith", "****", 2, tvApplicationTypeClient, "32402", , False
’ Get the User object
Set oUser = oSession.User
   
’ Get the Personal Status Folder
Set oPersonalStatusFolder = oSession.GetDefaultFolder(tvFolderPersonalStatus)
   
’ Look at each Personal status object in the folder until we find "*In A Meeting"
’ Note that the Name field of statuses are prefixed with "*"
For Each oPersonalStatus In oPersonalStatusFolder.Items
        If oPersonalStatus.Name = "*In A Meeting" Then
            ’ Use the ApplyStatus method with our "*In A Meeting" Personal status object
            oUser.ApplyStatus oPersonalStatus
        End If
    Next
   
’ Destroy objects and log off Server
    Set oUser = Nothing
    Set oPersonalStatusFolder = Nothing
    Set oPersonalStatus = Nothing
    oSession.LogOff
End SubCHAPTER 2. THE CLIENT API 2-33
TELEVANTAGE DEVELO

das habe ich schon und das funktioniert bis dahin auch.


Delphi-Quellcode:

  oCallFolder, oCallFolderHistory, oPersonalStatusFolder : Televantage_TLB.Folder;
  oCallItems, oCallItemsHistory : Televantage_TLB.Items;
  oPersonalStatus : Televantage_TLB.PersonalStatus;
  oUser : Televantage_TLB.User;



try
      oSession.Logon(AdvEdit6.Text,AdvEdit7.Text,AdvEdit8.Text,StrToInt(AdvEdit9.Text),tvApplicationTypeClient,34512,0,false,eStationUsage);
      if oSession.Status = tvSessionStatusLoggedOn then
      begin
//        tchkLogon.Enabled := True;
//        CoolTrayIcon1.IconIndex := 8;
//        CoolTrayicon1.Hint := Application.Exename + #13#10 + 'logon ok - ready for input';
//        CoolTrayIcon1.IconVisible := True;


        // Register for Call Events
        oCallFolder := oSession.GetDefaultFolder(tvFolderCalls);
        oCallItems := oCallFolder.Items;
        // Register for HistoryCall Events
        //oCallFolderHistory := oSession.GetDefaultFolder(tvFolderCallHistory);
        //oCallItemsHistory := oCallFolderHistory.Items;

        oUser := oSession.User;
        oPersonalStatusFolder := oSession.GetDefaultFolder(tvFolderPersonalStatus);

       



       // oSystemTargetFolder1 := v7Session1.GetDefaultFolder(tvFolderSystemTarget);
       // oTarget1 := _SystemTarget(oSystemTargetFolder1.Items.Item(AdvEdit7.Text,tvSearchkey));


      end;
    except
      AdvSmartMessageBox1.Messages.Items[2].Show;
      lblStatus.Caption := 'Error logon to Televantage Server';
      JFCLogFile1.LogText := 'btnLogOnLogOff -> Error logon to Televantage Server';

      Application.Terminate;
    end;
    btnLogOnLogOff.Caption := 'logoff';
    btnLogOnLogOff.Refresh;
    AdvSmartMessageBox1.Hide(0);
  end
  else
  begin
    oSession.LogOff;
    btnLogOnLogOff.Caption := 'logd off';
    AdvSmartMessageBox1.Messages.Items[0].Hide;
  end;

bin für jede Hilfe dankbar

Martin

TonyR 13. Mär 2011 14:39

AW: VB to Delphi bräuchte Unterstützung
 
Kannst du bitte konkret schreiben, was noch übersetzt werden muss oder was eventuell nicht funktioniert!?
Glaub nicht, dass viele Leute erstmal Zeile für Zeile gucken möchten, was noch fehlt.

Grüße, Tony

Edit: Und was ist das für ein Code-Stück, gehört das zu einem Chatprogramm?

EWeiss 13. Mär 2011 14:44

AW: VB to Delphi bräuchte Unterstützung
 
Das alles kannst du vergessen..
Zitat:

CoolTrayIcon1
Das ist eine ActiveX Control oder aber UserControl im Projekt integriert.

Zitat:

Private WithEvents oSession As Session
gehört zu einer Classe Session
welche mit getter und setter und Events gefüllt ist.
Ohne die Classe kannst du hier nichts übersetzen.
Die Events dieser Classe sind im Kopf (Public) exclusiv eingebunden.

gruss

msickel 13. Mär 2011 14:52

AW: VB to Delphi bräuchte Unterstützung
 
Zitat:

Zitat von TonyR (Beitrag 1088090)
Kannst du bitte konkret schreiben, was noch übersetzt werden muss oder was eventuell nicht funktioniert!?
Glaub nicht, dass viele Leute erstmal Zeile für Zeile gucken möchten, was noch fehlt.

Grüße, Tony

Edit: Und was ist das für ein Code-Stück, gehört das zu einem Chatprogramm?

Stimmt :-)

Hauptsächlich gehts mir um die For Each Schleife!

Delphi-Quellcode:
For Each oPersonalStatus In oPersonalStatusFolder.Items
        If oPersonalStatus.Name = "*In A Meeting" Then
            ’ Use the ApplyStatus method with our "*In A Meeting" Personal status object
            oUser.ApplyStatus oPersonalStatus
        End If
    Next

Martin

EWeiss 13. Mär 2011 14:59

AW: VB to Delphi bräuchte Unterstützung
 
Delphi-Quellcode:
For Each oPersonalStatus In oPersonalStatusFolder.Items
        If oPersonalStatus.Name = "*In A Meeting" Then
            ’ Use the ApplyStatus method with our "*In A Meeting" Personal status object
            oUser.ApplyStatus oPersonalStatus
        End If
    Next
Die Schleife wird solange durchlaufen bis kein item in oPersonalStatusFolder mehr gefunden wird.
Wird der Eintrag "In A Meeting" gefunden wird der ApplyStatus aktualisiert.
Normalerweise gehört hier in dem Fall noch ein "Exit For" dazu damit er rausspringen kann wenn das ergebnis true ist.

gruss

mkinzler 13. Mär 2011 15:00

AW: VB to Delphi bräuchte Unterstützung
 
Delphi-Quellcode:
For i := 0 to oPersonalStatusFolder.Items.Count - 1 do

EWeiss 13. Mär 2011 15:03

AW: VB to Delphi bräuchte Unterstützung
 
Zitat:

Zitat von mkinzler (Beitrag 1088101)
Delphi-Quellcode:
For i := 0 to oPersonalStatusFolder.Items.Count - 1 do

jo nur so einfach wollte ich es ihm nicht machen ;)

gruss

TonyR 13. Mär 2011 15:11

AW: VB to Delphi bräuchte Unterstützung
 
So müsste es wohl prinzipiell aussehen
Delphi-Quellcode:
for i:=0 to AnzahlDerElementeVon_oPersonalStatusFolder.Items - 1 do
  begin
  if oPersonalStatusFolder.Items[i].Name = '*In A Meeting' then
     oUser.ApplyStatus(oPersonalStatusFolder.Items[i]);
  end;
aber wie Emil schon geschrieben hat, man kann das so nicht übersetzen, da man die komplette verwendete Klasse übersetzen muss. (Siehst du ja bei "AnzahlDerElementeVon_oPersonalStatusFolder.It ems" ... da muss man wissen, was der Typ für Optionen bietet, um die Anzahl der Elemente zu bekommen)

EWeiss 13. Mär 2011 15:15

AW: VB to Delphi bräuchte Unterstützung
 
Zitat:

Zitat von TonyR (Beitrag 1088114)
So müsste es wohl prinzipiell aussehen
Delphi-Quellcode:
for i:=0 to AnzahlDerElementeVon_oPersonalStatusFolder.Items - 1 do
  begin
  if oPersonalStatusFolder.Items[i].Name = '*In A Meeting' then
     oUser.ApplyStatus(oPersonalStatusFolder.Items[i]);
  end;
aber wie Emil schon geschrieben hat, man kann das so nicht übersetzen, da man die komplette verwendete Klasse übersetzen muss. (Siehst du ja bei "AnzahlDerElementeVon_oPersonalStatusFolder.It ems" ... da muss man wissen, was der Typ für Optionen bietet, um die Anzahl der Elemente zu bekommen)

Dein Ansatz ist Korrekt!
Da er aber nicht über die Klasse verfügt und nicht weiß was dort steht geht es nun mal nicht.
Aber das sagtest du schon. ;)
Es sei denn er hat sie und macht sich die arbeit diese zu übersetzen.

gruss

msickel 13. Mär 2011 15:17

AW: VB to Delphi bräuchte Unterstützung
 
Zitat:

Zitat von mkinzler (Beitrag 1088101)
Delphi-Quellcode:
For i := 0 to oPersonalStatusFolder.Items.Count - 1 do

Danke,
das hatte ich auch schon so war mir aber nicht sicher ob das richtig ist.

noch eine Frage, wie würde den das übersetzt?

Delphi-Quellcode:

Private WithEvents oSession As Session

Dim oSession As New Session
Martin


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:49 Uhr.
Seite 1 von 2  1 2      

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