Solved

VCL Wrapper for Comobject

Posted on 2000-05-16
8
385 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
 

Expert Comment

by:MacNapple
ID: 2816192
I seem to remember it does.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now