operty doesn''''t exist, only that you won''''t be able to access it through a COM interface.
The Pascal Version of the Type Library unit ButtonXControlLib;
{ This file represents the pascal declarations
of a type library and will be written during each import or
refresh of the type library editor. Changes to this file will
be discarded during the refresh process. }
{ ButtonXControlLib Library }
{ Version 1.0 }
interface
uses Windows, ActiveX, Classes, Graphics, OleCtrls, StdVCL;
const LIBID_ButtonXControlLib: TGUID = ''''{B12863C0-A9EA-11D0-A6DF-444553540000}'''';
const
{ TxDragMode }
dmManual = 0;
dmAutomatic = 1;
{ TxMouseButton }
mbLeft = 0;
mbRight = 1;
mbMiddle = 2;
const
{ Component class GUIDs }
Class_ButtonX: TGUID = ''''{B12863C3-A9EA-11D0-A6DF-444553540000}'''';
type
{ Forward declarations }
IButtonX = interface;
DButtonX_ = dispinterface;
IButtonXEvents = dispinterface;
ButtonX = IButtonX;
TxDragMode = TOleEnum;
TxMouseButton = TOleEnum;
{ Dispatch interface for ButtonX Control }
IButtonX = interface(IDispatch)
[''''{B12863C1-A9EA-11D0-A6DF-444553540000}'''']
This is the control''''s main (dual) automation interface. The controller object''''s class will implement all these methods. procedure Click; safecall;
function Get_Cancel: WordBool; safecall;
procedure Set_Cancel(Value:WordBool); safecall;
function Get_Caption: WideString; safecall;
procedure Set_Caption(constValue: WideString); safecall;
function Get_Default: WordBool; safecall;
procedure Set_Default(Value: WordBool); safecall;
function Get_DragCursor: Smallint; safecall;
procedure Set_DragCursor(Value: Smallint); safecall;
function Get_DragMode: TxDragMode; safecall;
procedure Set_DragMode(Value: TxDragMode); safecall;
function Get_Enabled: WordBool; safecall;
procedure Set_Enabled(Value: WordBool); safecall;
function Get_Font: Font; safecall;
procedure Set_Font(const Value: Font); safecall;
function Get_ModalResult: Integer; safecall;
procedure Set_ModalResult(Value: Integer); safecall;
function Get_Visible: WordBool; safecall;
procedure Set_Visible(Value: WordBool); safecall;
function Get_Cursor: Smallint; safecall;
procedure Set_Cursor(Value: Smallint); safecall;
property Cancel: WordBool read Get_Cancel write Set_Cancel;
property Caption: WideString read Get_Caption write Set_Caption;
property Default: WordBool read Get_Default write Set_Default;
property DragCursor: Smallint read Get_DragCursor write Set_DragCursor;
property DragMode: TxDragMode read Get_DragMode write Set_DragMode;
property Enabled: WordBool read Get_Enabled write Set_Enabled;
property Font: Font read Get_Font write Set_Font;
property ModalResult: Integer read Get_ModalResult write Set_ModalResult;
property Visible: WordBool read Get_Visible write Set_Visible;
property Cursor: Smallint read Get_Cursor write Set_Cursor;
end;
{ DispInterface declaration for Dual Interface IButtonX }
DButtonX_ = dispinterface [''''{B12863C1-A9EA-11D0-A6DF-444553540000}'''']
This is the dispinterface version of the dual interface above. procedure Click; dispid 1;
property Cancel: WordBool dispid 2;
property Caption: WideString dispid 3;
property Default: WordBool dispid 4;
property DragCursor: Smallint dispid 5;
property DragMode: TxDragMode dispid 6;
property Enabled: WordBool dispid 7;
property Font: Font dispid 8;
property ModalResult: Integer dispid 9;
property Visible: WordBool dispid 10;
property Cursor: Smallint dispid 11;
end;
{ Events interface for ButtonX Control }
IButtonXEvents = dispinterface
[''''{B12863C2-A9EA-11D0-A6DF-444553540000}'''']
This is the events dispinterface for the control. The control can fire these events to its container if the container installs an event sink. procedure OnClick; dispid 1;
procedure OnKeyPress(var Key: Smallint); dispid 2;
end;
[Note: This file also includes declarations for TButtonX, which is the VCL class generated when you import the ButtonX control back into Delphi. For brevity''''s sake, I''''ve deleted this from this listing.] implementation
end.
Advanced Features
The DAX class hierarchy provides mechanisms for you to implement or customize certain features of ActiveX controls. These features include per-property browsing, persistence streaming, verbs, property pages, ambient properties, and registration.
TActiveXControl defines an immense number of protected methods, most of which are simply implementations of its interface methods. Because they''''re just interface method implementations, you probably won''''t need to override any of them. Nevertheless, they are protected to allow for extending the hierarchy over time, especially as Microsoft defines new behaviors and changes existing ones.
This still leaves a few protected methods you might want to override in specific circumstances. The following sections describe these situations.
Per Property Browsing
Property browsing support allows a property inspector to display a property that doesn''''t normally have a text representation, such as a font. It also allows the inspector to show a dropdown list of values that the property can have. You only need to implement per property browsing where normal variant conversions can''''t convert your data to a string or won''''t do it in the way you want.
Per-property browsing is implemented using three methods that work together: GetPropertyString, GetProperty Strings, and GetPropertyValue. function GetPropertyString(DispID: Integer; var S: string): Boolean;
When the property inspector displays a property, it calls this method to see if the property has a display string. If you want your property to have a display string, add a case statement for the property, calculate the string you want to show for the property''''s current value, and return True. Otherwise, return False;
Example: The following code demonstrates how you can show the Cursor property as a string surrounded by square brackets. function TButtonX.GetPropertyString( id: Integer; var S: String): Boolean;
begin
case id of
10: {Caption}
begin
S := ''''['''' + IntToStr( Get_Cursor ) +'''']'''';
Result := True;
end;
else
Result := False;
end;
end;
Bug: There was a bug in the shipping version of Delphi 3.0, which may be fixed by the time you read this. The implementation of TActiveXControl.GetDisplayString was left blank, when it should actually pass control to the GetPropertyString method mentioned above. Fortunately, this is easy to work around, since it simply requires supplying an implementation for IPerPropertyBrowsing.GetDisplayString. The following code shows the two places to modify the code to reimplement GetDisplayString correctly, in the class definition and in the class implementation.
TButtonX = class(TActiveXControl, IButtonX, IPerPropertyBrowsing)
...
function GetDisplayString(dispid: TDispID; out bstr: WideString):HResult; stdcall;
...
end;
...
function TButtonX.GetDisplayString(dispid: TDispID; out bstr: WideString): HResult;var S: String;
begin
if GetPropertyString( dispid, S ) then
begin
bstr := S;
Result := S_OK;
end
else
Result := E_NOTIMPL;
end;
function GetPropertyStrings(DispID: Integer; Strings: TStrings): Boolean;
GetPropertyStrings and GetPropertyValue work in tandem. GetPropertyStrings is called to populate a string list with a list of values that will be shown in a dropdown listbox. Once the user selects one of these, GetPropertyValues is called to retrieve the variant value for the selected property. procedure GetPropertyStrings(DispID: Integer; Strings: Tstrings): Boolean;
begin
if DispID = DISPID_FOO then
begin
Strings.Add(''''Ten'''');
Strings.Add(''''Twenty'''');
Strings.Add(''''Thirty'''');
Result := True;
end
else
Result := False;
end;
procedure GetPropertyValue(DispID, Cookie: Integer; var Value: OleVariant);
begin
if dispid = DISPID_FOO then
Value := Cookie *10;
end;
Custom Object Streaming
The default streaming behavior for DAX objects is to read or write all the property values from the VCL control using the VCL format. You can add extra information to the persistence stream by overriding the LoadFromStream or SaveToStream methods. Be sure to call the inherited method in order to load or save the control''''s properties properly.
These methods are defined as: procedure LoadFromStream(const Stream: IStream); procedureSaveToStream(const Stream: IStream);
They read 上一页 [1] [2] [3] [4] [5] [6] [7] [8] 下一页 |