Results 1 to 10 of 13

Thread: Create New Com Automation Class

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3

    Default Re: Create New Com Automation Class

    Michael,

    Object reference? Do you mean interface dispatch?

    If you return a variant in your ActiveX code then -obviously- it cannot return anything else.
    A variant data type hides the actual data type, it can be any data type underneath as is seen in the DataFlex package variant.pkg
    DataFlex cannot unhide that for you as it is dynamic.

    If you're talking about an IDispatch interface then DataFlex will always return the same, like if it is an IUnknown interface.
    Which ofcourse it is, but a derived interface.

    In other languages, say for example VB6, you get the interface type and down there that is _incredibly_ handy due to dot notation.

    Example in VB6:
    Code:
    Private Sub EdgeWebBrowser_OnNewWindowRequested(ByVal Args As AntViewAx.IAntViewNewWindowRequestedEventArgs)
      Dim URI As String
      Args.Handled = True
      URI = Args.URI
      EdgeWebBrowser.Navigate URI
    End Sub
    As you can see the parameter Args gets the data type interface AntviewAx.IAntViewNewWindowRequestedEventArgs

    If you want to do the same thing as above in DataFlex then it looks like this:

    First off this is what the class generates:
    Code:
        { MethodType=Event }
        Procedure OnComNewWindowRequested Variant llArgs
        End_Procedure
    "Variant" llArgs

    If you then want to do what was a few lines in VB6 ...

    Code:
        Procedure OnComNewWindowRequested Variant llArgs
          Boolean bIsComObjectCreated
          Handle  hoObj
          String  sURI
          If (IsComObject(llArgs)) Begin
            Get Create (RefClass(cComAntViewNewWindowRequestedEventArgs)) to hoObj
            If (hoObj) Begin
              Get IsComObjectCreated of hoObj to bIsComObjectCreated
              If (not(bIsComObjectCreated)) Begin
                  Send CreateComObject of hoObj
              End
              Set pvComObject of hoObj to llArgs
              Set ComHandled of hoObj to True
              Get ComURI of hoObj to sURI
              Send ComNavigate sURI
              Send Destroy of hoObj
            End
          End
        End_Procedure
    The problem here is DataFlex.
    Even if you had the interface as a data type, you still would have to write a lot more code to do the same thing.

    The good thing is that it is all boiler plate code, so it is easy to write once you've done it a few times.

    The bad thing is that it is not easy to read and that DataFlex doesn't even follow basic rules on ActiveX like the automatic garbage collection (which is debatable)

    edit: obviously this is also fine in VB6

    Code:
    Private Sub EdgeWebBrowser_OnNewWindowRequested(ByVal Args As AntViewAx.IAntViewNewWindowRequestedEventArgs)
      Args.Handled = True
      EdgeWebBrowser.Navigate Args.URI
    End Sub
    Sorry for making VB6 so complicated
    --
    Wil
    Last edited by wila; 30-Apr-2022 at 03:26 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •