home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 August
/
VPR9708A.ISO
/
D3TRIAL
/
INSTALL
/
DATA.Z
/
AXCTRLS.INT
< prev
next >
Wrap
Text File
|
1997-03-20
|
23KB
|
585 lines
{*******************************************************}
{ }
{ Delphi Visual Component Library }
{ ActiveX Controls Unit }
{ }
{ Copyright (c) 1997 Borland International }
{ }
{*******************************************************}
unit AxCtrls;
interface
uses
Windows, Messages, ActiveX, SysUtils, ComObj, Classes, Graphics,
Controls, Forms, Consts, ExtCtrls, StdVcl;
const
{ Delphi property page CLSIDs }
Class_DColorPropPage: TGUID = '{5CFF5D59-5946-11D0-BDEF-00A024D1875C}';
Class_DFontPropPage: TGUID = '{5CFF5D5B-5946-11D0-BDEF-00A024D1875C}';
Class_DPicturePropPage: TGUID = '{5CFF5D5A-5946-11D0-BDEF-00A024D1875C}';
Class_DStringPropPage: TGUID = '{F42D677E-754B-11D0-BDFB-00A024D1875C}';
type
TOleStream = class(TStream)
public
constructor Create(const Stream: IStream);
function Read(var Buffer; Count: Longint): Longint; override;
function Write(const Buffer; Count: Longint): Longint; override;
function Seek(Offset: Longint; Origin: Word): Longint; override;
end;
TAggregatedObject = class
protected
{ IUnknown }
function QueryInterface(const IID: TGUID; out Obj): Integer; stdcall;
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
public
constructor Create(const Controller: IUnknown);
property Controller: IUnknown;
end;
TContainedObject = class(TAggregatedObject, IUnknown)
protected
{ IUnknown }
function QueryInterface(const IID: TGUID; out Obj): Integer; virtual; stdcall;
end;
TConnectionPoints = class;
TConnectEvent = procedure (const Sink: IUnknown; Connecting: Boolean) of object;
TConnectionKind = (ckSingle, ckMulti);
TConnectionPoint = class(TContainedObject, IConnectionPoint)
protected
{ IConnectionPoint }
function GetConnectionInterface(out iid: TIID): HResult; stdcall;
function GetConnectionPointContainer(
out cpc: IConnectionPointContainer): HResult; stdcall;
function Advise(const unkSink: IUnknown; out dwCookie: Longint): HResult; stdcall;
function Unadvise(dwCookie: Longint): HResult; stdcall;
function EnumConnections(out enum: IEnumConnections): HResult; stdcall;
public
constructor Create(Container: TConnectionPoints;
const IID: TGUID; Kind: TConnectionKind; OnConnect: TConnectEvent);
destructor Destroy; override;
end;
TConnectionPoints = class(TAggregatedObject,
IConnectionPointContainer)
protected
{ IConnectionPointContainer }
function EnumConnectionPoints(
out enum: IEnumConnectionPoints): HResult; stdcall;
function FindConnectionPoint(const iid: TIID;
out cp: IConnectionPoint): HResult; stdcall;
public
constructor Create(const Controller: IUnknown);
destructor Destroy; override;
function CreateConnectionPoint(const IID: TGUID; Kind: TConnectionKind;
OnConnect: TConnectEvent): TConnectionPoint;
end;
TDefinePropertyPage = procedure(const GUID: TGUID) of object;
TActiveXControlFactory = class;
IAmbientDispatch = dispinterface
['{00020400-0000-0000-C000-000000000046}']
property BackColor: Integer dispid DISPID_AMBIENT_BACKCOLOR;
property DisplayName: WideString dispid DISPID_AMBIENT_DISPLAYNAME;
property Font: IFontDisp dispid DISPID_AMBIENT_FONT;
property ForeColor: Integer dispid DISPID_AMBIENT_FORECOLOR;
property LocaleID: Integer dispid DISPID_AMBIENT_LOCALEID;
property MessageReflect: WordBool dispid DISPID_AMBIENT_MESSAGEREFLECT;
property ScaleUnits: WideString dispid DISPID_AMBIENT_SCALEUNITS;
property TextAlign: Smallint dispid DISPID_AMBIENT_TEXTALIGN;
property UserMode: WordBool dispid DISPID_AMBIENT_USERMODE;
property UIDead: WordBool dispid DISPID_AMBIENT_UIDEAD;
property ShowGrabHandles: WordBool dispid DISPID_AMBIENT_SHOWGRABHANDLES;
property ShowHatching: WordBool dispid DISPID_AMBIENT_SHOWHATCHING;
property DisplayAsDefault: WordBool dispid DISPID_AMBIENT_DISPLAYASDEFAULT;
property SupportsMnemonics: WordBool dispid DISPID_AMBIENT_SUPPORTSMNEMONICS;
property AutoClip: WordBool dispid DISPID_AMBIENT_AUTOCLIP;
end;
TActiveXControl = class(TAutoObject,
IPersistStreamInit,
IPersistStorage,
IOleObject,
IOleControl,
IOleInPlaceObject,
IOleInPlaceActiveObject,
IViewObject,
IViewObject2,
IPerPropertyBrowsing,
ISpecifyPropertyPages,
ISimpleFrameSite)
protected
{ Renamed methods }
function IPersistStreamInit.Load = PersistStreamLoad;
function IPersistStreamInit.Save = PersistStreamSave;
function IPersistStorage.InitNew = PersistStorageInitNew;
function IPersistStorage.Load = PersistStorageLoad;
function IPersistStorage.Save = PersistStorageSave;
function IViewObject2.GetExtent = ViewObjectGetExtent;
{ IPersist }
function GetClassID(out classID: TCLSID): HResult; stdcall;
{ IPersistStreamInit }
function IsDirty: HResult; stdcall;
function PersistStreamLoad(const stm: IStream): HResult; stdcall;
function PersistStreamSave(const stm: IStream;
fClearDirty: BOOL): HResult; stdcall;
function GetSizeMax(out cbSize: Largeint): HResult; stdcall;
function InitNew: HResult; stdcall;
{ IPersistStorage }
function PersistStorageInitNew(const stg: IStorage): HResult; stdcall;
function PersistStorageLoad(const stg: IStorage): HResult; stdcall;
function PersistStorageSave(const stgSave: IStorage;
fSameAsLoad: BOOL): HResult; stdcall;
function SaveCompleted(const stgNew: IStorage): HResult; stdcall;
function HandsOffStorage: HResult; stdcall;
{ IOleObject }
function SetClientSite(const clientSite: IOleClientSite): HResult;
stdcall;
function GetClientSite(out clientSite: IOleClientSite): HResult;
stdcall;
function SetHostNames(szContainerApp: POleStr;
szContainerObj: POleStr): HResult; stdcall;
function Close(dwSaveOption: Longint): HResult; stdcall;
function SetMoniker(dwWhichMoniker: Longint; const mk: IMoniker): HResult;
stdcall;
function GetMoniker(dwAssign: Longint; dwWhichMoniker: Longint;
out mk: IMoniker): HResult; stdcall;
function InitFromData(const dataObject: IDataObject; fCreation: BOOL;
dwReserved: Longint): HResult; stdcall;
function GetClipboardData(dwReserved: Longint;
out dataObject: IDataObject): HResult; stdcall;
function DoVerb(iVerb: Longint; msg: PMsg; const activeSite: IOleClientSite;
lindex: Longint; hwndParent: HWND; const posRect: TRect): HResult;
stdcall;
function EnumVerbs(out enumOleVerb: IEnumOleVerb): HResult; stdcall;
function Update: HResult; stdcall;
function IsUpToDate: HResult; stdcall;
function GetUserClassID(out clsid: TCLSID): HResult; stdcall;
function GetUserType(dwFormOfType: Longint; out pszUserType: POleStr): HResult;
stdcall;
function SetExtent(dwDrawAspect: Longint; const size: TPoint): HResult;
stdcall;
function GetExtent(dwDrawAspect: Longint; out size: TPoint): HResult;
stdcall;
function Advise(const advSink: IAdviseSink; out dwConnection: Longint): HResult;
stdcall;
function Unadvise(dwConnection: Longint): HResult; stdcall;
function EnumAdvise(out enumAdvise: IEnumStatData): HResult; stdcall;
function GetMiscStatus(dwAspect: Longint; out dwStatus: Longint): HResult;
stdcall;
function SetColorScheme(const logpal: TLogPalette): HResult; stdcall;
{ IOleControl }
function GetControlInfo(var ci: TControlInfo): HResult; stdcall;
function OnMnemonic(msg: PMsg): HResult; stdcall;
function OnAmbientPropertyChange(dispid: TDispID): HResult; stdcall;
function FreezeEvents(bFreeze: BOOL): HResult; stdcall;
{ IOleWindow }
function GetWindow(out wnd: HWnd): HResult; stdcall;
function ContextSensitiveHelp(fEnterMode: BOOL): HResult; stdcall;
{ IOleInPlaceObject }
function InPlaceDeactivate: HResult; stdcall;
function UIDeactivate: HResult; stdcall;
function SetObjectRects(const rcPosRect: TRect;
const rcClipRect: TRect): HResult; stdcall;
function ReactivateAndUndo: HResult; stdcall;
{ IOleInPlaceActiveObject }
function TranslateAccelerator(var msg: TMsg): HResult; stdcall;
function OnFrameWindowActivate(fActivate: BOOL): HResult; stdcall;
function OnDocWindowActivate(fActivate: BOOL): HResult; stdcall;
function ResizeBorder(const rcBorder: TRect; const uiWindow: IOleInPlaceUIWindow;
fFrameWindow: BOOL): HResult; stdcall;
function EnableModeless(fEnable: BOOL): HResult; stdcall;
{ IViewObject }
function Draw(dwDrawAspect: Longint; lindex: Longint; pvAspect: Pointer;
ptd: PDVTargetDevice; hicTargetDev: HDC; hdcDraw: HDC;
prcBounds: PRect; prcWBounds: PRect; fnContinue: TContinueFunc;
dwContinue: Longint): HResult; stdcall;
function GetColorSet(dwDrawAspect: Longint; lindex: Longint;
pvAspect: Pointer; ptd: PDVTargetDevice; hicTargetDev: HDC;
out colorSet: PLogPalette): HResult; stdcall;
function Freeze(dwDrawAspect: Longint; lindex: Longint; pvAspect: Pointer;
out dwFreeze: Longint): HResult; stdcall;
function Unfreeze(dwFreeze: Longint): HResult; stdcall;
function SetAdvise(aspects: Longint; advf: Longint;
const advSink: IAdviseSink): HResult; stdcall;
function GetAdvise(pAspects: PLongint; pAdvf: PLONGINT;
out advSink: IAdviseSink): HResult; stdcall;
{ IViewObject2 }
function ViewObjectGetExtent(dwDrawAspect: Longint; lindex: Longint;
ptd: PDVTargetDevice; out size: TPoint): HResult; stdcall;
{ IPerPropertyBrowsing }
function GetDisplayString(dispid: TDispID; out bstr: WideString): HResult; stdcall;
function MapPropertyToPage(dispid: TDispID; out clsid: TCLSID): HResult; stdcall;
function GetPredefinedStrings(dispid: TDispID; out caStringsOut: TCAPOleStr;
out caCookiesOut: TCALongint): HResult; stdcall;
function GetPredefinedValue(dispid: TDispID; dwCookie: Longint;
out varOut: OleVariant): HResult; stdcall;
{ ISpecifyPropertyPages }
function GetPages(out pages: TCAGUID): HResult; stdcall;
{ ISimpleFrameSite }
function PreMessageFilter(wnd: HWnd; msg, wp, lp: Integer;
out res: Integer; out Cookie: Longint): HResult; stdcall;
function PostMessageFilter(wnd: HWnd; msg, wp, lp: Integer;
out res: Integer; Cookie: Longint): HResult; stdcall;
{ Standard properties }
function Get_BackColor: Integer; safecall;
function Get_Caption: WideString; safecall;
function Get_Enabled: WordBool; safecall;
function Get_Font: Font; safecall;
function Get_ForeColor: Integer; safecall;
function Get_HWnd: Integer; safecall;
function Get_TabStop: WordBool; safecall;
function Get_Text: WideString; safecall;
procedure Set_BackColor(Value: Integer); safecall;
procedure Set_Caption(const Value: WideString); safecall;
procedure Set_Enabled(Value: WordBool); safecall;
procedure Set_Font(const Value: Font); safecall;
procedure Set_ForeColor(Value: Integer); safecall;
procedure Set_TabStop(Value: WordBool); safecall;
procedure Set_Text(const Value: WideString); safecall;
{ Standard event handlers }
procedure StdClickEvent(Sender: TObject);
procedure StdDblClickEvent(Sender: TObject);
procedure StdKeyDownEvent(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure StdKeyPressEvent(Sender: TObject; var Key: Char);
procedure StdKeyUpEvent(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure StdMouseDownEvent(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure StdMouseMoveEvent(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
procedure StdMouseUpEvent(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
{ Helper methods }
function InPlaceActivate(ActivateUI: Boolean): HResult;
procedure ShowPropertyDialog;
{ Overrideable methods }
procedure DefinePropertyPages(
DefinePropertyPage: TDefinePropertyPage); virtual;
procedure EventSinkChanged(const EventSink: IUnknown); virtual;
function GetPropertyString(DispID: Integer;
var S: string): Boolean; virtual;
function GetPropertyStrings(DispID: Integer;
Strings: TStrings): Boolean; virtual;
procedure GetPropertyValue(DispID, Cookie: Integer;
var Value: OleVariant); virtual;
procedure InitializeControl; virtual;
procedure LoadFromStream(const Stream: IStream); virtual;
procedure PerformVerb(Verb: Integer); virtual;
procedure SaveToStream(const Stream: IStream); virtual;
procedure WndProc(var Message: TMessage); virtual;
public
destructor Destroy; override;
procedure Initialize; override;
function ObjQueryInterface(const IID: TGUID; out Obj): Integer; override;
function PropRequestEdit(const PropertyName: WideString): Boolean;
procedure PropChanged(const PropertyName: WideString);
property Control: TWinControl;
end;
TActiveXControlClass = class of TActiveXControl;
TActiveXControlFactory = class(TAutoObjectFactory)
protected
function GetLicenseFileName: string; virtual;
function HasMachineLicense: Boolean; override;
public
constructor Create(ComServer: TComServerObject;
ActiveXControlClass: TActiveXControlClass;
WinControlClass: TWinControlClass; const ClassID: TGUID;
ToolboxBitmapID: Integer; const LicStr: string; MiscStatus: Integer);
destructor Destroy; override;
procedure AddVerb(Verb: Integer; const VerbName: string);
procedure UpdateRegistry(Register: Boolean); override;
property EventIID: TGUID;
property EventTypeInfo: ITypeInfo;
property MiscStatus: Integer;
property ToolboxBitmapID: Integer;
property WinControlClass: TWinControlClass;
end;
{ ActiveFormControl }
TActiveFormControl = class(TActiveXControl, IVCLComObject)
protected
procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
procedure EventSinkChanged(const EventSink: IUnknown); override;
public
procedure FreeOnRelease;
procedure InitializeControl; override;
function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult;
override;
function ObjQueryInterface(const IID: TGUID; out Obj): Integer; override;
end;
{ ActiveForm }
TActiveFormBorderStyle = (afbNone, afbSingle, afbSunken, afbRaised);
TActiveForm = class(TCustomForm)
protected
procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); virtual;
procedure CreateParams(var Params: TCreateParams); override;
procedure EventSinkChanged(const EventSink: IUnknown); virtual;
procedure Initialize; virtual;
public
constructor Create(AOwner: TComponent); override;
function WantChildKey(Child: TControl; var Message: TMessage): Boolean; override;
published
property ActiveControl;
property AutoScroll;
property AxBorderStyle: TActiveFormBorderStyle default afbSingle;
property Caption stored True;
property Color;
property Font;
property Height stored True;
property HorzScrollBar;
property KeyPreview;
property PixelsPerInch;
property PopupMenu;
property PrintScale;
property Scaled;
property ShowHint;
property VertScrollBar;
property Width stored True;
property OnActivate;
property OnClick;
property OnCreate;
property OnDblClick;
property OnDestroy;
property OnDeactivate;
property OnDragDrop;
property OnDragOver;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnPaint;
end;
TActiveFormClass = class of TActiveForm;
{ ActiveFormFactory }
TActiveFormFactory = class(TActiveXControlFactory)
public
function GetIntfEntry(Guid: TGUID): PInterfaceEntry; override;
end;
{ Property Page support }
TActiveXPropertyPage = class;
TPropertyPage = class(TCustomForm)
public
procedure Modified;
procedure UpdateObject; virtual;
procedure UpdatePropertyPage; virtual;
property OleObject: Variant;
procedure EnumCtlProps(PropType: TGUID; PropNames: TStrings);
published
property ActiveControl;
property AutoScroll;
property Caption;
property ClientHeight;
property ClientWidth;
property Ctl3D;
property Color;
property Enabled;
property Font;
property Height;
property HorzScrollBar;
property KeyPreview;
property PixelsPerInch;
property ParentFont;
property PopupMenu;
property PrintScale;
property Scaled;
property ShowHint;
property VertScrollBar;
property Visible;
property Width;
property OnActivate;
property OnClick;
property OnClose;
property OnCreate;
property OnDblClick;
property OnDestroy;
property OnDeactivate;
property OnDragDrop;
property OnDragOver;
property OnHide;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnPaint;
property OnResize;
property OnShow;
end;
TPropertyPageClass = class of TPropertyPage;
TActiveXPropertyPage = class(TComObject,
IPropertyPage,
IPropertyPage2)
protected
{ IPropertyPage }
function SetPageSite(const pageSite: IPropertyPageSite): HResult; stdcall;
function Activate(hwndParent: HWnd; const rc: TRect; bModal: BOOL): HResult;
stdcall;
function Deactivate: HResult; stdcall;
function GetPageInfo(out pageInfo: TPropPageInfo): HResult; stdcall;
function SetObjects(cObjects: Longint; pUnkList: PUnknownList): HResult; stdcall;
function Show(nCmdShow: Integer): HResult; stdcall;
function Move(const rect: TRect): HResult; stdcall;
function IsPageDirty: HResult; stdcall;
function Apply: HResult; stdcall;
function Help(pszHelpDir: POleStr): HResult; stdcall;
function TranslateAccelerator(msg: PMsg): HResult; stdcall;
{ IPropertyPage2 }
function EditProperty(dispid: TDispID): HResult; stdcall;
public
destructor Destroy; override;
procedure Initialize; override;
end;
TActiveXPropertyPageFactory = class(TComObjectFactory)
protected
function CreateComObject(const Controller: IUnknown): TComObject; override;
public
constructor Create(ComServer: TComServerObject;
PropertyPageClass: TPropertyPageClass; const ClassID: TGUID);
end;
{ Type adapter support }
TCustomAdapter = class(TInterfacedObject)
protected
Updating: Boolean;
procedure Changed; virtual;
procedure ConnectOleObject(OleObject: IUnknown);
procedure ReleaseOleObject;
procedure Update; virtual; abstract;
public
constructor Create;
destructor Destroy; override;
end;
TAdapterNotifier = class(TInterfacedObject,
IPropertyNotifySink)
protected
{ IPropertyNotifySink }
function OnChanged(dispid: TDispID): HResult; stdcall;
function OnRequestEdit(dispid: TDispID): HResult; stdcall;
public
constructor Create(Adapter: TCustomAdapter);
end;
IFontAccess = interface
['{CBA55CA0-0E57-11D0-BD2F-0020AF0E5B81}']
procedure GetOleFont(var OleFont: IFontDisp);
procedure SetOleFont(const OleFont: IFontDisp);
end;
TFontAdapter = class(TCustomAdapter,
IChangeNotifier,
IFontAccess)
protected
{ IFontAccess }
procedure GetOleFont(var OleFont: IFontDisp);
procedure SetOleFont(const OleFont: IFontDisp);
procedure Changed; override;
procedure Update; override;
public
constructor Create(Font: TFont);
end;
IPictureAccess = interface
['{795D4D31-43D7-11D0-9E92-0020AF3D82DA}']
procedure GetOlePicture(var OlePicture: IPictureDisp);
procedure SetOlePicture(const OlePicture: IPictureDisp);
end;
TPictureAdapter = class(TCustomAdapter,
IChangeNotifier,
IPictureAccess)
protected
{ IPictureAccess }
procedure GetOlePicture(var OlePicture: IPictureDisp);
procedure SetOlePicture(const OlePicture: IPictureDisp);
procedure Update; override;
public
constructor Create(Picture: TPicture);
end;
TOleGraphic = class(TGraphic)
protected
procedure Changed(Sender: TObject); override;
procedure Draw(ACanvas: TCanvas; const Rect: TRect); override;
function GetEmpty: Boolean; override;
function GetHeight: Integer; override;
function GetPalette: HPALETTE; override;
function GetTransparent: Boolean; override;
function GetWidth: Integer; override;
procedure SetHeight(Value: Integer); override;
procedure SetPalette(Value: HPALETTE); override;
procedure SetWidth(Value: Integer); override;
public
procedure Assign(Source: TPersistent); override;
procedure LoadFromFile(const Filename: string); override;
procedure LoadFromStream(Stream: TStream); override;
procedure SaveToStream(Stream: TStream); override;
procedure LoadFromClipboardFormat(AFormat: Word; AData: THandle;
APalette: HPALETTE); override;
procedure SaveToClipboardFormat(var AFormat: Word; var AData: THandle;
var APalette: HPALETTE); override;
property MMHeight: Integer; // in .01 mm units
property MMWidth: Integer;
property Picture: IPicture;
end;
TStringsAdapter = class(TAutoIntfObject, IStrings, IStringsAdapter)
protected
{ IStringsAdapter }
procedure ReferenceStrings(S: TStrings);
procedure ReleaseStrings;
{ IStrings }
function Get_ControlDefault(Index: Integer): OleVariant; safecall;
procedure Set_ControlDefault(Index: Integer; Value: OleVariant); safecall;
function Count: Integer; safecall;
function Get_Item(Index: Integer): OleVariant; safecall;
procedure Set_Item(Index: Integer; Value: OleVariant); safecall;
procedure Remove(Index: Integer); safecall;
procedure Clear; safecall;
function Add(Item: OleVariant): Integer; safecall;
function _NewEnum: IUnknown; safecall;
public
constructor Create(Strings: TStrings);
end;
procedure GetOleFont(Font: TFont; var OleFont: IFontDisp);
procedure SetOleFont(Font: TFont; const OleFont: IFontDisp);
procedure GetOlePicture(Picture: TPicture; var OlePicture: IPictureDisp);
procedure SetOlePicture(Picture: TPicture; const OlePicture: IPictureDisp);
procedure GetOleStrings(Strings: TStrings; var OleStrings: IStrings);
procedure SetOleStrings(Strings: TStrings; const OleStrings: IStrings);
implementation