Groups > Borland > Borland C plus plus builder Active X > Re: ActiveX newbie struggling with interface




ActiveX newbie struggling with interface

ActiveX newbie struggling with interface
10 Apr 2008 19:55:18 -0700
I have successfully imported an ActiveX control and am able to
drop it on a form and compile, link and run the application.  For
the very most bare functionality of the control, it works 
perfectly.

...but I need to go beyond what's wrapped in the _OXC.h and dive
into the _TLB.h stuff, and I'm getting stuck quickly.

I have perused all the examples I can find, such as at the
Temporal Gate site, a year-old thread from this newsgroup, etc.,
but I'm just not getting it.  I can seemingly use some of the
properties and methods, but others cause A/Vs and other fireworks
when the program is run.

I can post or otherwise provide the Builder-generated _TLB.h file
or anything else that might help.  All the vendor's examples are
in VB or C#, and haven't been very much help.  I can provide some
of that code as well, if need be.

This is an URGENT project, so I will be extremely grateful for
any help anyone can provide.

Post Reply
Re: ActiveX newbie struggling with interface
Thu, 10 Apr 2008 21:19:35 -070
"TerryC" <user@server.net> wrote in message 
news:47fed316$1@newsgroups.borland.com...

> I can seemingly use some of the properties and methods, but
> others cause A/Vs and other fireworks when the program is run.

Then you are not accessing them correctly.  Please show your actual code.


Gambit 

Post Reply
Re: ActiveX newbie struggling with interface
10 Apr 2008 21:54:01 -0700
>> I can seemingly use some of the properties and methods, but
>> others cause A/Vs and other fireworks when the program is 
>> run.
>
>Then you are not accessing them correctly.  Please show your 
>actual code.

class TForm1 : public TForm
{
__published:	// IDE-managed Components
	TComponentControl *Map1;
	void __fastcall FormShow(TObject *Sender);
private:	// User declarations
public:		// User declarations
	__fastcall TForm1(TComponent* Owner);
};

void __fastcall TForm1::FormShow(TObject *Sender)
{
	AppPtr pMyApp;
	DocumentPtr pMyDoc;
	PointPtr pMyPoint;
	GeomPtr pMyGeom;
	DrawingPtr pMyDrawing;

	Map1->ZoomToFit();

	pMyApp = Map1->Application;
	pMyPoint = pMyApp->NewPoint(2386413.8564484678, 606160.24591498845);
	pMyGeom = pMyApp->NewGeom(GeomPoint, TVariantInParam((IUnknown*)pMyPoint));
	pMyDoc = Map1->ControlInterface->get_Document();
	pMyDrawing =
pMyDoc->NewDrawing(WideString("NewDrawing").c_bstr(),
			TVariantInParam((IUnknown*)pMyApp->DefaultCoordinateSystemLatLon),
			true);

// This line makes it blow up, so I have it commented out
//	pMyDrawing->ObjectSet->Add(TVariantInParam((IUnknown*)pMyGeom));
}

Do you need to see some of the _TLB.h file too?  I don't know
how much is too much to post in a message.  The file is huge.

Post Reply
Re: ActiveX newbie struggling with interface
Fri, 11 Apr 2008 01:59:49 -070
"TerryC" <user@server.net> wrote in message 
news:47feeee9$1@newsgroups.borland.com...

> pMyGeom = pMyApp->NewGeom(GeomPoint, 
> TVariantInParam((IUnknown*)pMyPoint));

Why are you using TVariantInParam like that?

    pMyGeom = pMyApp->NewGeom(GeomPoint, pMyPoint);

> pMyDoc = Map1->ControlInterface->get_Document();

Have you tried the Document property?

     pMyDoc = Map1->ControlInterface->Document;

> pMyDrawing =
pMyDoc->NewDrawing(WideString("NewDrawing").c_bstr(),
> TVariantInParam((IUnknown*)pMyApp->DefaultCoordinateSystemLatLon),
> true);

You do not need to call WideString::c_bstr().

    pMyDrawing = pMyDoc->NewDrawing(WideString("NewDrawing"), 
pMyApp->DefaultCoordinateSystemLatLon), true);

> // This line makes it blow up, so I have it commented out
> // pMyDrawing->ObjectSet->Add(TVariantInParam((IUnknown*)pMyGeom));

You are not checking to make sure that pMyDrawing and pMyGeom are not NULL 
first:

    if( (pMyDrawing) && (pMyGeom) )
        pMyDrawing->ObjectSet->Add(pMyGeom);

or:

    if( (pMyDrawing) && (pMyGeom) )
    {
        ObjectSetPtr ObjectSet = pMyDrawing->ObjectSet;
        if( ObjectSet )
            ObjectStr->Add(pMyGeom);
    }


Gambit 

Post Reply
Re: ActiveX newbie struggling with interface
13 Apr 2008 21:51:50 -0700
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>> pMyGeom = pMyApp->NewGeom(GeomPoint, 
>> TVariantInParam((IUnknown*)pMyPoint));
>
>Why are you using TVariantInParam like that?

The NewGeom() method expects that type as an argument.  If I
don't cast it that way, the compiler stops and complains.

>    pMyGeom = pMyApp->NewGeom(GeomPoint, pMyPoint);
>
>> pMyDoc = Map1->ControlInterface->get_Document();
>
>Have you tried the Document property?

There isn't one.  That's what's so frustrating with this
stuff!  There doesn't seem to be any rhyme or reason for what's
where and why.

>
>     pMyDoc = Map1->ControlInterface->Document;
>
>> pMyDrawing =
pMyDoc->NewDrawing(WideString("NewDrawing").c_bstr(),
>> TVariantInParam((IUnknown*)pMyApp->DefaultCoordinateSystemLatLon),
>> true);
>
>You do not need to call WideString::c_bstr().

OK.

>
>    pMyDrawing = pMyDoc->NewDrawing(WideString("NewDrawing"), 
>pMyApp->DefaultCoordinateSystemLatLon), true);
>
>> // This line makes it blow up, so I have it commented out
>> //
pMyDrawing->ObjectSet->Add(TVariantInParam((IUnknown*)pMyGeom));
>
>You are not checking to make sure that pMyDrawing and pMyGeom 
>are not NULL first:
>
>    if( (pMyDrawing) && (pMyGeom) )
>        pMyDrawing->ObjectSet->Add(pMyGeom);
>
>or:
>
>    if( (pMyDrawing) && (pMyGeom) )
>    {
>        ObjectSetPtr ObjectSet = pMyDrawing->ObjectSet;
>        if( ObjectSet )
>            ObjectStr->Add(pMyGeom);
>    }

Tried that, and pMyGeom is NULL at that point.

In fact, I'd like to back up to one of the first assignments:

{
...
   AppPtr pMyApp;
   PointPtr pMyPoint;

   pMyApp = Map1->Application;
   pMyPoint = pMyApp->NewPoint(2386413.8564484678,
         606160.24591498845);

   // With the debugger breaking at this line, and stepping
   // through it, pMyPoint is NULL at this stage.  I need to
   // figure out why.
...
}

A bit from the _TLB.h file:

// *********************************************************************//
// Interface: IApplication
// Flags:     (4096) Dispatchable
// GUID:      
// *********************************************************************//
interface IApplication : public TDispWrapper<IDispatch>
{
...
  Manifold_tlb::PointPtr __fastcall NewPoint(double dX/*[in,def,opt]*/, double
dY/*[in,def,opt]*/)
  {
    _TDispID _dispid(/* NewPoint */ DISPID(1610809399));
    TAutoArgs<2> _args;
    _args[1] = dX /*[VT_R8:0]*/;
    _args[2] = dY /*[VT_R8:0]*/;
    OleFunction(_dispid, _args);
    return (Manifold_tlb::Point* /*[C1]*/)(LPDISPATCH)
/*[VT_DISPATCH:1]*/_args.GetRetVariant();
  }
...
}

By the way... this is on BCB 5 Professional, Windows XP Home...

Many thanks,
Post Reply
<< Previous 1 2 3 4 Next >>
( Page 1 of 4 )
about | contact