lindsoe
asked on
VCL Wrapper for Comobject
Need short demo showing the right way to wrap a comobject in VCL component.
listening
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...
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...
I seem to remember it does.
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
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
ASKER
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
If I'm wrong and you mean some other kind of com object, sorry. That would depend much more on the com object itself.