Announcement

Collapse
No announcement yet.

VB-Code nach Delphi

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • VB-Code nach Delphi

    Hallo

    Ich muss den untenstehenden VB-Code in Delphi übersetzen. Doch leider hab ich keinen Schimmer von VB. Kann mir da jemand helfen?

    <PRE>
    Private Sub TestIAC()

    Dim doc As IDocument
    Dim app As IApplication
    Dim pMxDoc As IMxDocument
    Dim pobjectFactory As IObjectFactory
    Dim rot As AppROT
    Dim strName As String
    Set rot = New esriCore.AppROT
    Set app = rot.Item(0)
    Set pobjectFactory = app
    Set pMxDoc = app.Document

    Dim pActiveView As IActiveView
    Set pActiveView = pMxDoc.ActiveView
    MsgBox app.Name

    Dim pMap As IMap
    Dim pFeatureLayer As IFeatureLayer
    Dim pFeatureSelection As IFeatureSelection
    Dim pQueryFilter As IQueryFilter

    Set pMxDoc = app.Document
    Set pMap = pMxDoc.FocusMap
    'Set pActiveView = pMap

    'For simplicity sake let's use the first layer in the map
    If Not TypeOf pMap.Layer(0) Is IFeatureLayer Then Exit Sub
    Set pFeatureLayer = pMap.Layer(0)
    Set pFeatureSelection = pFeatureLayer 'QI

    'Create the query filter
    Set pQueryFilter = New QueryFilter
    pQueryFilter.WhereClause = "Id = 2"

    'Invalidate only the selection cache
    'Flag the original selection
    pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
    'Perform the selection
    pFeatureSelection.SelectFeatures pQueryFilter, esriSelectionResultNew, False
    'Flag the new selection
    pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing

    End Sub
    </PRE>

    Besten Dank

    Gruss

  • #2
    Hallo!<br>
    Ohne es jetzt komplett zu übersetzen:<br>
    Ich gehe mal davon aus, dass Du die entsprechenden Typbibliotheken (ist es ArcObjects?) importiert hast. Sonst wird der Compiler Alle Typen mit I.. nicht kennen.<br>
    <br>
    Alles mit DIM sind Variablendeklarationen:<br>
    Dim doc As IDocument<br>
    Delphi: var doc : IDocument;<br>
    <br>
    New:<br>
    Set pQueryFilter = New QueryFilter <br>
    Delphi: pQueryFilter := CoQueryFilter.create;<br>
    <br>
    Alles mit Set sind Zuweisungen:<br>
    Set pMxDoc = app.Document <br>
    Delphi: pMxDoc := app.Document;<br>
    <br>
    Funktionsaufrufe:<br>
    pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing <br>
    Delphi: pActiveView.PartialRefresh ( esriViewGeoSelection, EmptyParam, EmptyParam );<br>
    <br>
    Kann es sein, dass "esriCore" eine globale Variable ist?<br>
    Vielleicht hilft der kleine "Ansatz" ja schon ein wenig.....<br>
    BYE BERN

    Comment


    • #3
      Hallo Bernd

      Vorab vielen Dank für Deine Hilfe.
      Nun habe ich das Problem, dass beim Import
      der Typbibliotheken die Klassennamen geändert
      wurden.
      Weisst Du, wie man dieses Namesänderungen
      nachvollziehen kann ?

      Gruss Ur

      Comment


      • #4
        Hallo,

        &gt;..Import der Typbibliotheken die Klassennamen geändert wurden.

        Diese Namen sind für COM "Schall und Rauch" und daher beliebig wählbar - wichtig sind nur die CLSID und IID, die als GUID (Global Unique Identifier) exakt übereinstimmen müssen.

        Beim Import einer Typbibliothek kann man die in der Mitte (TMemo) angezeigten Klassennamen von Hand ändern, bevor die Unit angelegt wird. Allerdings muss man darauf auchen, dass dort keine Namen auftauchen, bis bereits in Delphi (VCL) als Bezeichnernamen verwendet werden

        Comment

        Working...
        X