
String-Problems calling callback function in VB6 ActiveX-Control from C++
Hi!
I'm relative new to Visual Basic, but pretty comfortable with C/C++.
I want to call a C/C++ generated DLL from within a VB ActiveX Control.
More precisely, I want to give the DLL the pointer of a callback-
function
and the DLL calls this function in the ActiveX Control.
While I managed it to set up the callback-mechanism, I have problems
with
the data. The C/C++ DLL calls the VB ActiveX function with a C/C++
struct
like this:
typedef struct tagDATA {
long Number1;
long Number2;
char String1[100];
char String2[100];
Quote:
} *LPDATA;
The prototype in C/C++ looks like this:
void ActiveXCallbackFunction(LPDATA lpData);
I converted this to VB:
Public Type DATA
Number1 As Long
Number2 As Long
String1 As String * 100
String2 As String * 100
End Type
The Callback-Function in the VB Control looks like this:
Public Sub CallbackFunction(ByRef lpData As DATA)
MsgBox CStr(lpData.Number1) ' Output: ok
MsgBox CStr(lpData.Number2) ' Output: ok
MsgBox lpData.String1 ' Output: "???"
MsgBox lpData.String2 ' Output: "???"
End Sub
The problem is, that the numbers are transmitted correctly,
but the strings are a mess, displaying "?" and spaces.
I have'nt found a way to do it in the documentation,
so I hope someone of you VB-pro's can help me on this.
TIA
Jochen
Sent via Deja.com http://www.*-*-*.com/
Before you buy.