Board index » cppbuilder » Passing BSTR to ActiveX Control in BCB3

Passing BSTR to ActiveX Control in BCB3

Hi, all.

I'm trying to send BSTRs ("wchar_t *"s) to a number of ActiveX Controls from
BCB3 similar to the following code snippet:

        AnsiString myAnsiString = "0000000.000";
        wchar_t *wbuffer = new wchar_t[80];
        myAnsiString.WideChar(wbuffer, 80);
        myPVDTColumnDisp.set_Format(wbuffer);

Whenever the last line of code runs (the code that actually tries to pass
the BSTR to the ActiveX Control), the BCB3 CPU window pops up in all its
glory and shows the following:

DbgBreakPoint:
77F76148    int 3
->77F76149    ret
77F7614A    mov eax,eax
DbgUserBreakPoint:
77F7614C    int 3
77F7614D    ret
77F7614E    mov eax,eax
77F76150    mov eax,[esp+0x04]
77F76154    int 3
77F76155    ret 0x0004
DbgPrint:
77F76158    push esp
...

This looks to me like a user breakpoint has been set, but when I go to the
"Breakpoint List" window, it's empty.

Also, the "Call Stack" window lists 77F76149 as being in "ntdll.dll" (I'm on
NT 4.0, SP3).

At any rate, I hit the "run" arrow a couple of times and the program just
keeps on going (no errors, and the called operation completes with the
expected outcome).

Any insights or suggestions?

TIA,

Paul.Ha...@JHUAPL.edu

 

Re:Passing BSTR to ActiveX Control in BCB3


I am a newbie at this too - but try StringToOleStr() function to convert
AnsiString to BSTR or Variant.
Quote
Paul Hanke wrote:

> Hi, all.

> I'm trying to send BSTRs ("wchar_t *"s) to a number of ActiveX Controls from
> BCB3 similar to the following code snippet:

>         AnsiString myAnsiString = "0000000.000";
>         wchar_t *wbuffer = new wchar_t[80];
>         myAnsiString.WideChar(wbuffer, 80);
>         myPVDTColumnDisp.set_Format(wbuffer);

> Whenever the last line of code runs (the code that actually tries to pass
> the BSTR to the ActiveX Control), the BCB3 CPU window pops up in all its
> glory and shows the following:

> DbgBreakPoint:
> 77F76148    int 3
> ->77F76149    ret
> 77F7614A    mov eax,eax
> DbgUserBreakPoint:
> 77F7614C    int 3
> 77F7614D    ret
> 77F7614E    mov eax,eax
> 77F76150    mov eax,[esp+0x04]
> 77F76154    int 3
> 77F76155    ret 0x0004
> DbgPrint:
> 77F76158    push esp
> ...

> This looks to me like a user breakpoint has been set, but when I go to the
> "Breakpoint List" window, it's empty.

> Also, the "Call Stack" window lists 77F76149 as being in "ntdll.dll" (I'm on
> NT 4.0, SP3).

> At any rate, I hit the "run" arrow a couple of times and the program just
> keeps on going (no errors, and the called operation completes with the
> expected outcome).

> Any insights or suggestions?

> TIA,

> Paul.Ha...@JHUAPL.edu

Re:Passing BSTR to ActiveX Control in BCB3


Try a WideString.
//jt

Re:Passing BSTR to ActiveX Control in BCB3


Do this:

{
   WideString wString = "0000000.000";
   myPVDTColumnDisp.set_Format(wString);

Quote
}
Paul Hanke wrote:

> Hi, all.

> I'm trying to send BSTRs ("wchar_t *"s) to a number of ActiveX Controls from
> BCB3 similar to the following code snippet:

>         AnsiString myAnsiString = "0000000.000";
>         wchar_t *wbuffer = new wchar_t[80];
>         myAnsiString.WideChar(wbuffer, 80);
>         myPVDTColumnDisp.set_Format(wbuffer);

> Whenever the last line of code runs (the code that actually tries to pass
> the BSTR to the ActiveX Control), the BCB3 CPU window pops up in all its
> glory and shows the following:

Other Threads