Solved

I am creating an ActiveX: How do I pass records?

Posted on 2001-06-18
16
231 Views
Last Modified: 2010-04-06
Hi,

I am in the process of making an ActiveX control in Delphi. I started out using the wizard and then added methods and some records in typelib on my own.

All works fine when I just pass an integer or other primitive types.

However, I have made some records in the typelib and I would like to pass either pointers to these or the records themselves in method calls:

E.g. I have a record:

  dxx_vector = packed record
    x: Single;
    y: Single;
    z: Single;
  end;

And I want to add this record to the ActiveX (is already done) and allow users of the ActiveX to access it (already works) and pass it as parameter (how?). And can this be done both as pass-by-value and pass-by-reference?

I tried adding a parameter of type "dxx_vector" but the resulting code just passes a TGUID. How do I use this to access the record or am I doing something complete wrong here?

Jacob Marner, B.Sc.
0
Comment
Question by:felonius
  • 8
  • 7
16 Comments
 
LVL 5

Expert Comment

by:TheNeil
ID: 6202539
Bit shaky on this subject but I think you need to pass it as an OLEVariant. It's been a while since I journeyed down this branch of Delphi and I remember anything else

The Neil =:)
0
 
LVL 1

Author Comment

by:felonius
ID: 6202615
Hmm,

I *can* get Delphi to show OLEVariant in the Delphi control implementation, if I in the typelib define it as VARIANT. However, the activeX client will then see it as a Variant which was not the intention. And even if I had to go with the variant solution I don't have the fainted idea on how to convert the OleVariant to my record.

Where do I find information about these kind of things. The Delphi on-line help is very brief on the subject of records in typelibs.

I would like to add that the first attempt I made by inserting a "dxx_vector" directly into the typelib specification seemed to work on activeX client side where it looked right. Unfortunately I just don't how in the Delphi implementation to handle the TGUID presented here.

A solution that can help me get on will be rewarded. If there is somebody that can help me out to get over this problem in a clean way I am even willy to raise the points to 500.

Jacob
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 300 total points
ID: 6202692
Those TGUID's are caused by a bug. Make sure you have the latest Delphi updates installed.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:Epsylon
ID: 6202764
I am using Delphi 5 Enterprise with Update pack 1 and I don't have this bug.

Here you can download the update(s):

http://www.borland.com/devsupport/delphi/downloads/index.html
0
 
LVL 1

Author Comment

by:felonius
ID: 6202910
Yes, updating Delphi certainly did the trick and the Delphi interface now is shown as the correct record type. How stupid of me not to have done that a long time ago...

No wonder, I couldn't get it to work.

Let me just check it out if it actually works.

Does any of you know whether it is possible to pass records both by value and by reference in an ActiveX. If so, how do I differentiate between them in typelib specification?

Jacob
0
 
LVL 1

Author Comment

by:felonius
ID: 6202965
Hmm, the ordeal does not seem over yet.

In the interface the signiture is like this: (autogenerated)

function  map_addinstance(const filename: WideString; origin: {??dxx_vector} OleVariant; angle: angle, locked: Integer): Integer; dispid 1;

And in the CoClass it is like this: (autogenerated)

    function map_addinstance(const filename: WideString; origin: dxx_vector; angle, locked: Integer): Integer; safecall;

These does not match. What is {??dxx_vector} and how do I get them to match?

Jacob
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6202973
In the parameter list (Parameters tab in the TypeLibrary window) you can set the type to dxx_vector to pass it as value, or as dxx_vector* to pass is as reference.
Also check out the pulldown menu. Your record must be listed twice in there somewhere...
0
 
LVL 1

Author Comment

by:felonius
ID: 6202974
The top one is pasted wrong. Here the real is:

function  map_addinstance(const filename: WideString; origin: {??dxx_vector} OleVariant; angle,
locked: Integer): Integer; dispid 1;

Sorry.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6203067
What kind of ActiveX project is it? ActiveForm, Automation Object or ComObject?
0
 
LVL 1

Author Comment

by:felonius
ID: 6203548
I clicked "new" and then in the ActiveX property page I selected "ActiveX control" - and that started a wizard. (Delphi 5 with update 1 :-) ) Without knowing for sure I assume that is an automation object.

I just tried creating some more methods with record parameters in them and it keeps happening this difference in declarations.

(Epsylon: As promised - if you get me through this (almost there I think) I will award extra points)

Jacob
0
 
LVL 1

Author Comment

by:felonius
ID: 6203629
Hmm, I just tried making new project with the wizard and it is all different with the update 1 installed. I suspect that Borland has made a number of changes and that may be what causes my code above to fail.

So for now I will just stop here and come back again later and ask more questions if needed.

Thank you all for your help.

Jacob Marner
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6203645
I'm not sure what you are trying to do but I think you started on the wrong track (I could be wrong).


For an automation object:

File menu > close all
File menu > new > ActiveX tab > ActiveX Library
File menu > new > ActiveX tab > Automation Object


For a COM object:

File menu > close all
File menu > new > ActiveX tab > ActiveX Library
File menu > new > ActiveX tab > COM Object
0
 
LVL 1

Author Comment

by:felonius
ID: 6203671
I need to do an actual Automation object (an OCX for use in visual basic). The old version I had of the same project was made the way I explained, but the code that wizards make now are different. So I think you are right - I redo the project architecture with the automation object wizard.

thanx.

(FYI: It is being used for a 3D engine. Check it out at www.eldermage.com)

Jacob
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6203815
Oh.. well.. thanks for the points  :o)

OCX is used for graphical objects, like buttons, listviews etc, or even whole forms. An Automation or COM object is a DLL when 'in-process server', or an exe when 'out-of-process server'.
0
 
LVL 1

Author Comment

by:felonius
ID: 6203828
I am making a graphical object (a rendering window). Does this mean I should use another wizard?

Jacob
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6262625
Hi Jacob, due to a bug in EE I don't receive email notifications anymore atfer you accpted my comment. This happens on all paqs :o(((

Do you still have problems?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question