Solved

VCL Wrapper for Comobject

Posted on 2000-05-16
8
391 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
  • 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 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