Re: ComClass + Events



Hallo Stefan,
verwende statt Events lieber Callback.
Erstelle eine Schnittstelle in VS mit Interface ... Callback,
erstelle eine Klasse in der du die Referenz vom VB6 Objekt merkst,
löse nachdem deien Berabeitung in VS abgeschlossen ist ein Callbackereignis
aus.
Implementiere diese Schnittstelle in VB 6 mit Implements Callback,
Übergebe in VB6 dein Objekt an die Callback Klasse,
Empfange das Ereignis
Das wars.

mfg Martin

"Mähr Stefan" <stefan.maehr@xxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:O57NBFBeGHA.3792@xxxxxxxxxxxxxxxxxxxxxxx
Hallo NG,

ich will eine in VB.NET 2005 erstellte DLL in VB6 benutzen, das
funktioniert soweit wunderbar, nur mit Events aus dieser DLL habe ich
Probleme.

Unterhalb folgt die Klassendefinition mit den beiden Events. Beide events
werden in der DLL auf jeden Fall aufgerufen.
Ich referenziere also die TLB in meinem VB6 Projekt, rufe die öffentliche
Prozedur darin auf und alles wird wunderbar ausgeführt, nur die Events des
mit WithEvents deklarierten Objekts werden nie ausgeführt ...

VB.NET ComClass

Public Class cFONWS

#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "76a79db3-1639-42e9-b3f1-67f36fd9e743"
Public Const InterfaceId As String =
"9e038995-6047-4883-b46b-d19ee98e29e3"
Public Const EventsId As String = "7f8fcf81-7787-4ff4-8252-7f51226787d2"
#End Region

' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub

Public Event SMSC_FONUebermittlung(ByVal ReturnCode As Integer, ByVal
FileSize As Double, ByVal FileCount As Integer, ByVal message As String)
Public Event SMSC_FONWSError(ByVal strError As String)

Aufrufendes VB6 Form

Private WithEvents fon As cFONWS
Private Sub Command1_Click()

Dim bolRet As Boolean

DoEvents
Set fon = New SMSC_FONWS.cFONWS
With fon
.BenuzterID = xxx
.Teilnehmercode = xxx
.Pin = xxx
.Dokument = xxx
.Uebermittlung = xxx
.Dateiname = xxx
bolRet = .DatenUebermitteln
End With

End Sub

Private Sub fon_SMSC_FONWSError(ByVal strError As String)
MsgBox strError
End Sub

Private Sub fon_SMSC_FONUebermittlung(ByVal ReturnCode As Long, ByVal
FileSize As Double, ByVal FileCount As Long, ByVal message As String)

Dim strOut As String

strOut = ReturnCode & vbCrLf & FileSize & vbCrLf & FileCount & vbCrLf &
message
MsgBox strOut

End Sub




.



Relevant Pages

  • Re: ComClass + Events
    ... verwende statt Events lieber Callback. ... erstelle eine Klasse in der du die Referenz vom VB6 Objekt merkst, ... ' A creatable COM class must have a Public Sub New() ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Callback from Fortran DLL to VB6
    ... It works in Compaq Fortran 6.6, ... which the program I'd like to incorporate the callback ... 'Fortran callback to VB6. ... Declare Sub Test_DLL Lib "Test_DLL" ...
    (comp.lang.fortran)
  • Re: Emulate AddressOf operator
    ... > any of it methods as a callback routine (in other words, ... Private Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ... Public Sub TimerProc() ... Public Property Let Interval ...
    (microsoft.public.vb.winapi)
  • Re: Handle leak in Windows 2003 Authorization Manager?
    ... Since the sample is in VB6, ... releases it's objects when the sub terminates. ... > keep the Authz context around as long as the app keeps the AzMan context ... > Best regards, ...
    (microsoft.public.platformsdk.security)
  • Re: Emulate AddressOf operator
    ... But surely the callback cannot access any class member variables, ... > Private Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ... > Public Sub TimerProc() ... > Public Property Let Interval ...
    (microsoft.public.vb.winapi)