Callback with wParam of Any type (vb and c++)
I am trying to make a callback in vc++ and vb (vc++ calls a function in vb) and one of the parameters passed to the function that calls the callback is passed to the callback, it's value ignored.
this is the same functionality of the lParam in EnumFontFamilies.
The declare (in vb) for the function defines wParam of my function as type Any. This allows me to pass numbers, objects, or strings to the callback function.
Unfortunatly, my code doesn't work correctly for this. It works for numbers variables (i.e. integer and long) and it works for variants, but it doesn't work with strings (the debug window shows "?????" for the value of wParam)
Here is the c++ code:
Code:
#include <windows.h>
typedef int (__stdcall *STATUSCALLBACK)(int uCalled, int uReturn, WPARAM wParam);
int __stdcall test(STATUSCALLBACK f, WPARAM wParam)
{
return f(123, 123, wParam);
}
here is the vb code:
VB Code:
Option Explicit
Declare Function test Lib "H:\Microsoft Visual Studio\MyProjects\callback\Debug\callback.dll" (ByVal cbkCallbackProc As Long, ByRef wParam As Any) As Long
Public Function CB(ByVal uCalled As Long, ByVal uReturn As Long, wParam As [b]Variant[/b]) As Long
Debug.Print "uCalled" & vbTab & uCalled
Debug.Print "uReturn" & vbTab & uReturn
Debug.Print "wParam" & vbTab & wParam
CB = 54321
End Function
Sub main()
Dim a As [b]Variant[/b]
a = "hello world"
Debug.Print "Return" & vbTab & test(AddressOf CB, a)
End Sub
i need to be able to put any data type, object type, or user-defined type in place of the variant type i used here