Two answers:
BoloBaby wrote:
> Take note that the sub that handles the event HAS to be in the standard
> module and NOT in a class module. This is just a limitation of VB6.0. This
> means that I can't raise any events in that sub... which is what I *really*
> need to do.
why don't you just invoke the class and let it handle the event? Just
declare an object of the class on module scope. In the class, before
calling the API, you set this object instance to "Me". then you can call
a public procedure of this class from the callback function. Now, back
in the class this certain public procedure uses RaiseEvent to raise an
event.
It's as simple as this.
> Anyway, the inability to raise events led me to try and set up a PInvoke
> wrapper in .NET. The problem is, the VB6.0 DLL for the digital I/O card
> accepts only "ByVal callbackAddr As Long" as the address for the callback
> function. In .NET, the AddressOf operator returns a System.Delegate type.
No problem at all, just declare the API accordingly, use the delegate
type. The framework will take care of the needed conversion.
Example:
\\
Public Delegate Function FontEnumProc( _
ByVal NLF As LOGFONT, _
ByVal NTM As TEXTMETRIC, _
ByVal FontType As Int32, _
ByVal LParam As Int32 _
) As Int32
Public Declare Function EnumFontFamilies Lib "gdi32" Alias
"EnumFontFamiliesA" ( _
ByVal hDC As Int32, _
ByVal lpszFamily As String, _
ByVal lpEnumFontFamProc As FontEnumProc, _
ByVal lParam As Int32 _
) As Long
///
should work just as well with your API.
--
Konrad -
http://madrat.net/