Board index » cppbuilder » Dirt Simple OCX Created in VB6 crashes when I call empty method in BCB4

Dirt Simple OCX Created in VB6 crashes when I call empty method in BCB4

Hello All,

I'm creating a 3rd party ActiveX component in VB6, and I'd love for it to be
compatible with Borlands product line.

I'm using BCB verson 4 with both service packs, under 98.

In an attempt to simplify the issue I've created a dirt simple OCX in VB
with one method, Empty().  The code generated by the import is shown at the
bottom of this message, and my implementation is immediately below:

void __fastcall TForm1::cbEmptySubClick(TObject *Sender)
{
  EmptyOCX11->EmptySub();

Quote
}

Simply calling this empty subroutine in my OCX calls a fault, " Project
Demo.EXE raised exception class EAccessViolation with message 'Access
violation at address 66023C23 in module 'MSVBVM60.DLL'.  Read of Address
FFFFFFFF'. Process stopped.  Use Step or Run to continue."

I must be doing something obviously wrong here, since I'm not even passing
parameters.

Any help is greatly appreciated,

Alen Seigel

------------------------------------------------------------------
  Code generated by importing the ACTIVEX
-----------------------------------------------------------------
// ************************************************************************
//
// WARNING
// -------
// The types declared in this file were generated from data read from a
// Type Library. If this type library is explicitly or indirectly (via
// another type library referring to this type library) re-imported, or the
// 'Refresh' command of the Type Library Editor activated while editing the
// Type Library, the contents of this file will be regenerated and all
// manual modifications will be lost.
// ************************************************************************
//

// C++ TLBWRTR : $Revision:   1.96.1.40  $
// File generated on 06/13/00 8:40:07 PM from Type Library described below.

// ************************************************************************
//
// Type Lib: C:\CLIENTS WORK IN PROGRESS\SII\EMPTYOCX\EMPTYOCX.OCX
// IID\LCID: {970F4D0C-4148-11D4-B48D-005004ADD3D9}\0
// Helpfile:
// DepndLst:
//   (1) v2.0 stdole, (C:\WINDOWS\SYSTEM\stdole2.tlb)
//   (2) v4.0 StdVCL, (C:\WINDOWS\SYSTEM\STDVCL40.DLL)
// ************************************************************************
//

#include <vcl.h>
#pragma hdrstop
#if defined(USING_ATL)
#include <atl\atlvcl.h>
#endif

#include "EmptyOCX_OCX.h"

#if !defined(__PRAGMA_PACKAGE_SMART_INIT)
#define      __PRAGMA_PACKAGE_SMART_INIT
#pragma package(smart_init)
#endif

namespace Emptyocx_tlb
{

// *********************************************************************//
// OCX PROXY CLASS IMPLEMENTATION
// (The following variables/methods implement the class TEmptyOCX1 which
// allows "" to be hosted in CBuilder IDE/apps).
// *********************************************************************//
TControlData TEmptyOCX1::CControlData =
{
  // GUID of CoClass and Event Interface of Control
  {0x970F4D0E, 0x4148, 0x11D4,{ 0xB4, 0x8D, 0x00, 0x50, 0x04, 0xAD, 0xD3,
0xD9} }, // CoClass
  {0x5C48CA20, 0x416A, 0x11D4,{ 0xB4, 0x8D, 0x00, 0x50, 0x04, 0xAD, 0xD3,
0xD9} }, // Events

  // Count of Events and array of their DISPIDs
  0, NULL,

  // Pointer to Runtime License string
  NULL,  // HRESULT(0x00000000)
  // Flags for OnChanged PropertyNotification
  0x00000000,
  300,// (IDE Version)

  // Count of Font Prop and array of their DISPIDs
  0, NULL,

  // Count of Pict Prop and array of their DISPIDs
  0, NULL,
  0, // Reserved
  0, // Instance count (used internally)
  0, // List of Enum descriptions (internal)

Quote
};

GUID     TEmptyOCX1::DEF_CTL_INTF = {0x5C48CA1F, 0x416A, 0x11D4,{ 0xB4,
0x8D, 0x00, 0x50, 0x04, 0xAD, 0xD3, 0xD9} };
TNoParam TEmptyOCX1::OptParam;

static inline void ValidCtrCheck(TEmptyOCX1 *)
{
   delete new TEmptyOCX1((TComponent*)(0));

Quote
};

void __fastcall TEmptyOCX1::InitControlData(void)
{
  ControlData = &CControlData;

Quote
};

void __fastcall TEmptyOCX1::CreateControl(void)
{
  if (!m_OCXIntf)
  {
    _ASSERTE(DefaultDispatch);
    DefaultDispatch->QueryInterface(DEF_CTL_INTF, (LPVOID*)&m_OCXIntf);
  }

Quote
};

TCOM_EmptyOCX1 __fastcall TEmptyOCX1::GetControlInterface(void)
{
  CreateControl();
  return m_OCXIntf;
Quote
};

void/*HR*/ __fastcall TEmptyOCX1::EmptySub(void)
{
  GetControlInterface().EmptySub();

Quote
}
};     // namespace Emptyocx_tlb

// *********************************************************************//
// The Register function is invoked by the IDE when this module is
// installed in a Package. It provides the list of Components (including
// OCXes) implemented by this module. The following implementation
// informs the IDE of the OCX proxy classes implemented here.
// *********************************************************************//
namespace Emptyocx_ocx
{

void __fastcall PACKAGE Register()
{
  // [1]
  TComponentClass classes[] = {
                              __classid(Emptyocx_tlb::TEmptyOCX1)
                             };
  RegisterComponents("ActiveX", classes,
                     sizeof(classes)/sizeof(classes[0])-1);

Quote
}
};     // namespace Emptyocx_ocx

 

Re:Dirt Simple OCX Created in VB6 crashes when I call empty method in BCB4


In article <8i6vj8$f...@bornews.borland.com>,

Quote
Allen Segall <aseg...@bigfoot.com> wrote:
>In an attempt to simplify the issue I've created a dirt simple OCX in VB
>with one method, Empty().  The code generated by the import is shown at the
>bottom of this message, and my implementation is immediately below:

>void __fastcall TForm1::cbEmptySubClick(TObject *Sender)
>{
>  EmptyOCX11->EmptySub();
>}

>Simply calling this empty subroutine in my OCX calls a fault, " Project
>Demo.EXE raised exception class EAccessViolation with message 'Access
>violation at address 66023C23 in module 'MSVBVM60.DLL'.  Read of Address
>FFFFFFFF'. Process stopped.  Use Step or Run to continue."
>I must be doing something obviously wrong here, since I'm not even passing
>parameters.

Maybe, maybe not. My bet is *BCB* is doing something wrong.

Try using the dispinterface wrapper rather than the direct interface
wrapper --- there's a problem in BCB4 (fixed in BCB5 patch 1) with
methods not being in the correct order for certain VB controls.
(Basically, we assumed that the methods were in the type library in the
order they were in the vtable; apparently that's not a correct assumption,
although it's hard to imagine an implementation which put them into
the type library in a different order ...)

--
Si vales, valeo.

Re:Dirt Simple OCX Created in VB6 crashes when I call empty method in BCB4


Allen, it is possible that VB creates COM servers with the sparse
vtables and BCB4 doesn't handle all cases of this. This is a bug in VB,
of course.

.a

Quote
Allen Segall wrote:

[snip]

Re:Dirt Simple OCX Created in VB6 crashes when I call empty method in BCB4


Thanks for the replies,

" Try using the dispinterface wrapper rather than the direct interface
 wrapper", how does one accomplish this?

Thanks,

Allen Segall

Quote
Robert West <aphr...@magescave.blackforest.org> wrote in message

news:8i8i13$c3o$1@sphinx.inprise.com...
Quote
> In article <8i6vj8$f...@bornews.borland.com>,
> Allen Segall <aseg...@bigfoot.com> wrote:
> >In an attempt to simplify the issue I've created a dirt simple OCX in VB
> >with one method, Empty().  The code generated by the import is shown at
the
> >bottom of this message, and my implementation is immediately below:

> >void __fastcall TForm1::cbEmptySubClick(TObject *Sender)
> >{
> >  EmptyOCX11->EmptySub();
> >}

> >Simply calling this empty subroutine in my OCX calls a fault, " Project
> >Demo.EXE raised exception class EAccessViolation with message 'Access
> >violation at address 66023C23 in module 'MSVBVM60.DLL'.  Read of Address
> >FFFFFFFF'. Process stopped.  Use Step or Run to continue."

> >I must be doing something obviously wrong here, since I'm not even
passing
> >parameters.

> Maybe, maybe not. My bet is *BCB* is doing something wrong.

> Try using the dispinterface wrapper rather than the direct interface
> wrapper --- there's a problem in BCB4 (fixed in BCB5 patch 1) with
> methods not being in the correct order for certain VB controls.
> (Basically, we assumed that the methods were in the type library in the
> order they were in the vtable; apparently that's not a correct assumption,
> although it's hard to imagine an implementation which put them into
> the type library in a different order ...)

> --
> Si vales, valeo.

Re:Dirt Simple OCX Created in VB6 crashes when I call empty method in BCB4


Additional info:  I've also tried this with Borland C++ Builder version 5.0
to no avail.

I would appreciated any advice, including what course of action to take
next.

Best Regards,

Allen Segall

Quote
Allen Segall <aseg...@bigfoot.com> wrote in message

news:8i6vj8$fgt4@bornews.borland.com...
Quote
> Hello All,

> I'm creating a 3rd party ActiveX component in VB6, and I'd love for it to
be
> compatible with Borlands product line.

> I'm using BCB verson 4 with both service packs, under 98.

> In an attempt to simplify the issue I've created a dirt simple OCX in VB
> with one method, Empty().  The code generated by the import is shown at
the
> bottom of this message, and my implementation is immediately below:

> void __fastcall TForm1::cbEmptySubClick(TObject *Sender)
> {
>   EmptyOCX11->EmptySub();
> }

> Simply calling this empty subroutine in my OCX calls a fault, " Project
> Demo.EXE raised exception class EAccessViolation with message 'Access
> violation at address 66023C23 in module 'MSVBVM60.DLL'.  Read of Address
> FFFFFFFF'. Process stopped.  Use Step or Run to continue."

> I must be doing something obviously wrong here, since I'm not even passing
> parameters.

> Any help is greatly appreciated,

> Alen Seigel

> ------------------------------------------------------------------
>   Code generated by importing the ACTIVEX
> -----------------------------------------------------------------
> //

************************************************************************
Quote
> //
> // WARNING
> // -------
> // The types declared in this file were generated from data read from a
> // Type Library. If this type library is explicitly or indirectly (via
> // another type library referring to this type library) re-imported, or
the
> // 'Refresh' command of the Type Library Editor activated while editing
the
> // Type Library, the contents of this file will be regenerated and all
> // manual modifications will be lost.
> //

************************************************************************
Quote
> //

> // C++ TLBWRTR : $Revision:   1.96.1.40  $
> // File generated on 06/13/00 8:40:07 PM from Type Library described
below.

> //

************************************************************************
Quote
> //
> // Type Lib: C:\CLIENTS WORK IN PROGRESS\SII\EMPTYOCX\EMPTYOCX.OCX
> // IID\LCID: {970F4D0C-4148-11D4-B48D-005004ADD3D9}\0
> // Helpfile:
> // DepndLst:
> //   (1) v2.0 stdole, (C:\WINDOWS\SYSTEM\stdole2.tlb)
> //   (2) v4.0 StdVCL, (C:\WINDOWS\SYSTEM\STDVCL40.DLL)
> //

************************************************************************

- Show quoted text -

Quote
> //

> #include <vcl.h>
> #pragma hdrstop

> #if defined(USING_ATL)
> #include <atl\atlvcl.h>
> #endif

> #include "EmptyOCX_OCX.h"

> #if !defined(__PRAGMA_PACKAGE_SMART_INIT)
> #define      __PRAGMA_PACKAGE_SMART_INIT
> #pragma package(smart_init)
> #endif

> namespace Emptyocx_tlb
> {

> // *********************************************************************//
> // OCX PROXY CLASS IMPLEMENTATION
> // (The following variables/methods implement the class TEmptyOCX1 which
> // allows "" to be hosted in CBuilder IDE/apps).
> // *********************************************************************//
> TControlData TEmptyOCX1::CControlData =
> {
>   // GUID of CoClass and Event Interface of Control
>   {0x970F4D0E, 0x4148, 0x11D4,{ 0xB4, 0x8D, 0x00, 0x50, 0x04, 0xAD, 0xD3,
> 0xD9} }, // CoClass
>   {0x5C48CA20, 0x416A, 0x11D4,{ 0xB4, 0x8D, 0x00, 0x50, 0x04, 0xAD, 0xD3,
> 0xD9} }, // Events

>   // Count of Events and array of their DISPIDs
>   0, NULL,

>   // Pointer to Runtime License string
>   NULL,  // HRESULT(0x00000000)

>   // Flags for OnChanged PropertyNotification
>   0x00000000,
>   300,// (IDE Version)

>   // Count of Font Prop and array of their DISPIDs
>   0, NULL,

>   // Count of Pict Prop and array of their DISPIDs
>   0, NULL,
>   0, // Reserved
>   0, // Instance count (used internally)
>   0, // List of Enum descriptions (internal)
> };

> GUID     TEmptyOCX1::DEF_CTL_INTF = {0x5C48CA1F, 0x416A, 0x11D4,{ 0xB4,
> 0x8D, 0x00, 0x50, 0x04, 0xAD, 0xD3, 0xD9} };
> TNoParam TEmptyOCX1::OptParam;

> static inline void ValidCtrCheck(TEmptyOCX1 *)
> {
>    delete new TEmptyOCX1((TComponent*)(0));
> };

> void __fastcall TEmptyOCX1::InitControlData(void)
> {
>   ControlData = &CControlData;
> };

> void __fastcall TEmptyOCX1::CreateControl(void)
> {
>   if (!m_OCXIntf)
>   {
>     _ASSERTE(DefaultDispatch);
>     DefaultDispatch->QueryInterface(DEF_CTL_INTF, (LPVOID*)&m_OCXIntf);
>   }
> };

> TCOM_EmptyOCX1 __fastcall TEmptyOCX1::GetControlInterface(void)
> {
>   CreateControl();
>   return m_OCXIntf;
> };

> void/*HR*/ __fastcall TEmptyOCX1::EmptySub(void)
> {
>   GetControlInterface().EmptySub();
> }

> };     // namespace Emptyocx_tlb

> // *********************************************************************//
> // The Register function is invoked by the IDE when this module is
> // installed in a Package. It provides the list of Components (including
> // OCXes) implemented by this module. The following implementation
> // informs the IDE of the OCX proxy classes implemented here.
> // *********************************************************************//
> namespace Emptyocx_ocx
> {

> void __fastcall PACKAGE Register()
> {
>   // [1]
>   TComponentClass classes[] = {
>                               __classid(Emptyocx_tlb::TEmptyOCX1)
>                              };
>   RegisterComponents("ActiveX", classes,
>                      sizeof(classes)/sizeof(classes[0])-1);
> }
> };     // namespace Emptyocx_ocx

Re:Dirt Simple OCX Created in VB6 crashes when I call empty method in BCB4


It is possible that VB creates the vtable in a manner that is not
strictly COM compliant. BCB5, apparently, with the patch mentioned here
by Robert West, can handle such controls. I suggest you get a trial
version of BCB5, apply the patch and see if it works. Also, if you want,
you can email me a zip containing the control and I'll give it a try.

Alex

Quote
Allen Segall wrote:

[snip]

Other Threads