home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 August / VPR9708A.ISO / D3TRIAL / INSTALL / DATA.Z / OLECTRLS.INT < prev    next >
Text File  |  1997-03-21  |  7KB  |  161 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Visual Component Library                 }
  5. {                                                       }
  6. {       Copyright (c) 1996,97 Borland International     }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit OleCtrls;
  11.  
  12. {$R-}
  13.  
  14. interface
  15.  
  16. uses Windows, Messages, ActiveX, SysUtils, Classes, Controls, Forms,
  17.   Menus, Graphics, ComObj, AxCtrls;
  18.  
  19. type
  20.  
  21.   TOleControl = class;
  22.  
  23.   TEventDispatch = class(TObject, IUnknown, IDispatch)
  24.   public
  25.     constructor Create(Control: TOleControl);
  26.   end;
  27.  
  28.   TOleEnum = type Smallint;
  29.  
  30.   TEnumValue = record
  31.     Value: Longint;
  32.     Ident: string;
  33.   end;
  34.  
  35.   PEnumValueList = ^TEnumValueList;
  36.   TEnumValueList = array[0..32767] of TEnumValue;
  37.  
  38.   TEnumPropDesc = class
  39.   public
  40.     constructor Create(DispID, ValueCount: Integer;
  41.       const TypeInfo: ITypeInfo);
  42.     destructor Destroy; override;
  43.     procedure GetStrings(Proc: TGetStrProc);
  44.     function StringToValue(const S: string): Integer;
  45.     function ValueToString(V: Integer): string;
  46.   end;
  47.  
  48.   PControlData = ^TControlData;
  49.   TControlData = record
  50.     ClassID: TGUID;
  51.     EventIID: TGUID;
  52.     EventCount: Longint;
  53.     EventDispIDs: Pointer;
  54.     LicenseKey: Pointer;
  55.     Flags: Integer;
  56.     Version: Integer;
  57.     FontCount: Integer;
  58.     FontIDs: PDispIDList;
  59.     PictureCount: Integer;
  60.     PictureIDs: PDispIDList;
  61.     Reserved: Integer;
  62.     InstanceCount: Integer;
  63.     EnumPropDescs: TList;
  64.   end;
  65.  
  66.   TOleControl = class(TWinControl, IUnknown, IOleClientSite,
  67.     IOleControlSite, IOleInPlaceSite, IOleInPlaceFrame, IDispatch,
  68.     IPropertyNotifySink, ISimpleFrameSite)
  69.   protected
  70.     FEvents: Integer;
  71.     procedure CreateWnd; override;
  72.     procedure DefaultHandler(var Message); override;
  73.     procedure DefineProperties(Filer: TFiler); override;
  74.     procedure DestroyWindowHandle; override;
  75.     function GetByteProp(Index: Integer): Byte;
  76.     function GetColorProp(Index: Integer): TColor;
  77.     function GetTColorProp(Index: Integer): TColor;
  78.     function GetCompProp(Index: Integer): Comp;
  79.     function GetCurrencyProp(Index: Integer): Currency;
  80.     function GetDoubleProp(Index: Integer): Double;
  81.     function GetIDispatchProp(Index: Integer): IDispatch;
  82.     function GetIntegerProp(Index: Integer): Integer;
  83.     function GetIUnknownProp(Index: Integer): IUnknown;
  84.     function GetWordBoolProp(Index: Integer): WordBool;
  85.     function GetTDateTimeProp(Index: Integer): TDateTime;
  86.     function GetTFontProp(Index: Integer): TFont;
  87.     function GetOleBoolProp(Index: Integer): TOleBool;
  88.     function GetOleDateProp(Index: Integer): TOleDate;
  89.     function GetOleEnumProp(Index: Integer): TOleEnum;
  90.     function GetTOleEnumProp(Index: Integer): TOleEnum;
  91.     function GetOleVariantProp(Index: Integer): OleVariant;
  92.     function GetTPictureProp(Index: Integer): TPicture;
  93.     procedure GetProperty(Index: Integer; var Value: TVarData);
  94.     function GetShortIntProp(Index: Integer): ShortInt;
  95.     function GetSingleProp(Index: Integer): Single;
  96.     function GetSmallintProp(Index: Integer): Smallint;
  97.     function GetStringProp(Index: Integer): string;
  98.     function GetVariantProp(Index: Integer): Variant;
  99.     function GetWideStringProp(Index: Integer): WideString;
  100.     function GetWordProp(Index: Integer): Word;
  101.     procedure InitControlData; virtual; abstract;
  102.     procedure InitControlInterface(const Obj: IUnknown); virtual;
  103.     procedure InvokeMethod(const DispInfo; Result: Pointer);
  104.     function PaletteChanged(Foreground: Boolean): Boolean; override;
  105.     procedure PictureChanged(Sender: TObject);
  106.     procedure SetByteProp(Index: Integer; Value: Byte);
  107.     procedure SetColorProp(Index: Integer; Value: TColor);
  108.     procedure SetTColorProp(Index: Integer; Value: TColor);
  109.     procedure SetCompProp(Index: Integer; const Value: Comp);
  110.     procedure SetCurrencyProp(Index: Integer; const Value: Currency);
  111.     procedure SetDoubleProp(Index: Integer; const Value: Double);
  112.     procedure SetIDispatchProp(Index: Integer; const Value: IDispatch);
  113.     procedure SetIntegerProp(Index: Integer; Value: Integer);
  114.     procedure SetIUnknownProp(Index: Integer; const Value: IUnknown);
  115.     procedure SetName(const Value: TComponentName); override;
  116.     procedure SetWordBoolProp(Index: Integer; Value: WordBool);
  117.     procedure SetTDateTimeProp(Index: Integer; const Value: TDateTime);
  118.     procedure SetTFontProp(Index: Integer; const Value: TFont);
  119.     procedure SetOleBoolProp(Index: Integer; Value: TOleBool);
  120.     procedure SetOleDateProp(Index: Integer; const Value: TOleDate);
  121.     procedure SetOleEnumProp(Index: Integer; Value: TOleEnum);
  122.     procedure SetTOleEnumProp(Index: Integer; Value: TOleEnum);
  123.     procedure SetOleVariantProp(Index: Integer; const Value: OleVariant);
  124.     procedure SetParent(AParent: TWinControl); override;
  125.     procedure SetTPictureProp(Index: Integer; const Value: TPicture);
  126.     procedure SetProperty(Index: Integer; const Value: TVarData);
  127.     procedure SetShortIntProp(Index: Integer; Value: Shortint);
  128.     procedure SetSingleProp(Index: Integer; const Value: Single);
  129.     procedure SetSmallintProp(Index: Integer; Value: Smallint);
  130.     procedure SetStringProp(Index: Integer; const Value: string);
  131.     procedure SetVariantProp(Index: Integer; const Value: Variant);
  132.     procedure SetWideStringProp(Index: Integer; const Value: WideString);
  133.     procedure SetWordProp(Index: Integer; Value: Word);
  134.     procedure WndProc(var Message: TMessage); override;
  135.     property ControlData: PControlData;
  136.   public
  137.     constructor Create(AOwner: TComponent); override;
  138.     destructor Destroy; override;
  139.     procedure BrowseProperties;
  140.     procedure DoObjectVerb(Verb: Integer);
  141.     function GetEnumPropDesc(DispID: Integer): TEnumPropDesc;
  142.     function GetHelpContext(Member: string; var HelpCtx: Integer;
  143.       var HelpFile: string): Boolean;
  144.     procedure GetObjectVerbs(List: TStrings);
  145.     function GetPropDisplayString(DispID: Integer): string;
  146.     procedure GetPropDisplayStrings(DispID: Integer; List: TStrings);
  147.     function IsCustomProperty(DispID: Integer): Boolean;
  148.     procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
  149.     procedure SetPropDisplayString(DispID: Integer; const Value: string);
  150.     procedure ShowAboutBox;
  151.     property OleObject: Variant;
  152.     property TabStop default True;
  153.   end;
  154.  
  155.   EOleCtrlError = class(Exception);
  156.  
  157. function FontToOleFont(Font: TFont): Variant;
  158. procedure OleFontToFont(const OleFont: Variant; Font: TFont);
  159.  
  160. implementation
  161.