Solved

VCL Wrapper for Comobject

Posted on 2000-05-16
8
397 Views
Last Modified: 2008-02-26
Need short demo showing the right way to wrap a comobject in VCL component.
0
Comment
Question by:lindsoe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 

Expert Comment

by:MacNapple
ID: 2814650
When talking about a component, I assume you mean an ActiveX control? Those can be imported automatically into Delphi using Components/Import ActiveX.

If I'm wrong and you mean some other kind of com object, sorry. That would depend much more on the com object itself.
0
 
LVL 4

Expert Comment

by:mhervais
ID: 2815028
listening
0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2815297
if you're using D5 ...

Click on Project->Import type library
Find your type library...
Make sure "generate component wrapper" is checked, and click 'install'
That's it. Too easy.

I don't know if D4 does this, I never did any COM work with it...
0
Industry Leaders: 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!

 

Expert Comment

by:MacNapple
ID: 2816192
I seem to remember it does.
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2816571
Actually, all COM usage is finally a wrapper around an interface using some kind of Delphi class (often TInterfacedObject). Also importing an ActiveX (or IDLs for that matter) is nothing else than creating the correct VCL wrapper (perhaps with extra steps like constant and enumrants declarations etc.).

The general case of creating the VCL wrapper is:

1) create your interface you want to wrap:

  IVTEditLink = interface
    procedure BeginEdit;
    procedure CancelEdit;
    procedure EndEdit;
    :
    etc.
  end;

2) write the actual implementation for this (this is the actual wrapping):

  TStringEditLink = class(TInterfacedObject, IVTEditLink)
  private
    FEdit: TVTEdit; // a normal custom edit control
    :
  public
    constructor Create;
    destructor Destroy; override;

    procedure BeginEdit;
    procedure CancelEdit;
    procedure EndEdit;
    :
  end;

Here appear the declared methods (see IVTEditLink) again, but this time they get an actual implementation.

If you need to know more then just ask... :-)

Ciao, Mike
0
 

Author Comment

by:lindsoe
ID: 2816817
Thanks Mike, this is close to what I need. Could you give a few guidelines for when it is needed to create a CreateVCLComObjectProc as in vclcom.pas and when to implemet IVclComobject?
0
 
LVL 10

Accepted Solution

by:
Lischke earned 400 total points
ID: 2817621
Oh, I have done quite a lot with COM but I never saw this function until you mentioned it here. I doubt you will ever need this in normal projects. Judging from the fact that the only code which sets CreateVCLComObjectProc is in VCLCom.pas which is not included into Classes.pas (there's the variable which holds the procedure), I'd say there's some compiler magic involved here. I don't think you need CreateVCLComObjectProc anyway.

Ciao, Mike
0
 

Author Comment

by:lindsoe
ID: 2817808
Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

740 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