How expose the properties of an component created in an activex form
You can publish the properties of an control that is inside a activex form?
example I have a form with an TAdoconnection component, I wish the properties of this component can be modified by the user when he loads my activex control.
alt text http://i46.tinypic.com/2hd1xr4.png
UPDATE
@TOndrej gives me a very nice sample, but this sample only works for components derived from an activex control, how can accomplish this same efffect with an VCL component like an Timage or TMemo? is possible publish all the properties without rewrite each property to expose manually?
ADO components are already ActiveX objects, so the easiest way is to expose the connection as a simple property of your ActiveX form:
In the type library editor, add "Microsoft ActiveX Data Objects 2.1 Library" to the list of used libraries. This will generate ADODB_TLB.pas
unit in your project directory.
alt text http://i46.tinypic.com/2itfprm.png
Then you can declare a new read-only property Connection
of type Connection
(this type is declared in ADODB_TLB
unit) in your IActiveFormX
interface.
alt text http://i47.tinypic.com/2a5atf9.png
In the implementation, you can simply return the interface from your TADOConnection
component:
type
THackADOConnection = class(TADOConnection);
function TActiveFormX.Get_Connection: Connection;
begin
Result := Connection(THackADOConnection(ADOConnection).ConnectionObject);
end;
The THackADOConnection
typecast is only necessary because ConnectionObject
is protected. The outer Connection
typecast is there to get rid of the compiler error "Incompatible types: ADODB_TLB._Connection and ADOInt._Connection."
上一篇: 类似于iPad的滑块(开/关)式组件