home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161b.iso / full / delphi / INSTALL / data.z / EDITIMP.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-08-05  |  18.0 KB  |  686 lines

  1. unit EditImp;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, PBag_TLB;
  8.  
  9. type
  10.   TEditX = class(TActiveXControl, IEditX, IPersistPropertyBag)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TEdit;
  14.     FEvents: IEditXEvents;
  15.     procedure ChangeEvent(Sender: TObject);
  16.     procedure ClickEvent(Sender: TObject);
  17.     procedure DblClickEvent(Sender: TObject);
  18.     procedure KeyPressEvent(Sender: TObject; var Key: Char);
  19.   protected
  20.     { IPersistPropertyBag }
  21.     { Methods should be aliased so they don't collide with existing names }
  22.     function IPersistPropertyBag.InitNew = PersistPropBagInitNew;
  23.     function IPersistPropertyBag.Load = PersistPropBagLoad;
  24.     function IPersistPropertyBag.Save = PersistPropBagSave;
  25.     function PersistPropBagInitNew: HResult; stdcall;
  26.     function PersistPropBagLoad(const pPropBag: IPropertyBag;
  27.       const pErrorLog: IErrorLog): HResult; stdcall;
  28.     function PersistPropBagSave(const pPropBag: IPropertyBag; fClearDirty: BOOL;
  29.       fSaveAllProperties: BOOL): HResult; stdcall;
  30.     { Protected declarations }
  31.     procedure InitializeControl; override;
  32.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  33.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  34.     function Get_AutoSelect: WordBool; safecall;
  35.     function Get_AutoSize: WordBool; safecall;
  36.     function Get_BorderStyle: TxBorderStyle; safecall;
  37.     function Get_CharCase: TxEditCharCase; safecall;
  38.     function Get_Color: TColor; safecall;
  39.     function Get_Ctl3D: WordBool; safecall;
  40.     function Get_Cursor: Smallint; safecall;
  41.     function Get_DragCursor: Smallint; safecall;
  42.     function Get_DragMode: TxDragMode; safecall;
  43.     function Get_Enabled: WordBool; safecall;
  44.     function Get_Font: Font; safecall;
  45.     function Get_HideSelection: WordBool; safecall;
  46.     function Get_ImeMode: TxImeMode; safecall;
  47.     function Get_ImeName: WideString; safecall;
  48.     function Get_MaxLength: Integer; safecall;
  49.     function Get_Modified: WordBool; safecall;
  50.     function Get_OEMConvert: WordBool; safecall;
  51.     function Get_ParentColor: WordBool; safecall;
  52.     function Get_ParentCtl3D: WordBool; safecall;
  53.     function Get_PasswordChar: Smallint; safecall;
  54.     function Get_ReadOnly: WordBool; safecall;
  55.     function Get_SelLength: Integer; safecall;
  56.     function Get_SelStart: Integer; safecall;
  57.     function Get_SelText: WideString; safecall;
  58.     function Get_Text: WideString; safecall;
  59.     function Get_Visible: WordBool; safecall;
  60.     procedure AboutBox; safecall;
  61.     procedure Clear; safecall;
  62.     procedure ClearSelection; safecall;
  63.     procedure CopyToClipboard; safecall;
  64.     procedure CutToClipboard; safecall;
  65.     procedure PasteFromClipboard; safecall;
  66.     procedure SelectAll; safecall;
  67.     procedure Set_AutoSelect(Value: WordBool); safecall;
  68.     procedure Set_AutoSize(Value: WordBool); safecall;
  69.     procedure Set_BorderStyle(Value: TxBorderStyle); safecall;
  70.     procedure Set_CharCase(Value: TxEditCharCase); safecall;
  71.     procedure Set_Color(Value: TColor); safecall;
  72.     procedure Set_Ctl3D(Value: WordBool); safecall;
  73.     procedure Set_Cursor(Value: Smallint); safecall;
  74.     procedure Set_DragCursor(Value: Smallint); safecall;
  75.     procedure Set_DragMode(Value: TxDragMode); safecall;
  76.     procedure Set_Enabled(Value: WordBool); safecall;
  77.     procedure Set_Font(const Value: Font); safecall;
  78.     procedure Set_HideSelection(Value: WordBool); safecall;
  79.     procedure Set_ImeMode(Value: TxImeMode); safecall;
  80.     procedure Set_ImeName(const Value: WideString); safecall;
  81.     procedure Set_MaxLength(Value: Integer); safecall;
  82.     procedure Set_Modified(Value: WordBool); safecall;
  83.     procedure Set_OEMConvert(Value: WordBool); safecall;
  84.     procedure Set_ParentColor(Value: WordBool); safecall;
  85.     procedure Set_ParentCtl3D(Value: WordBool); safecall;
  86.     procedure Set_PasswordChar(Value: Smallint); safecall;
  87.     procedure Set_ReadOnly(Value: WordBool); safecall;
  88.     procedure Set_SelLength(Value: Integer); safecall;
  89.     procedure Set_SelStart(Value: Integer); safecall;
  90.     procedure Set_SelText(const Value: WideString); safecall;
  91.     procedure Set_Text(const Value: WideString); safecall;
  92.     procedure Set_Visible(Value: WordBool); safecall;
  93.   end;
  94.  
  95. implementation
  96.  
  97. uses SysUtils, ComObj, About1;
  98.  
  99. { Helper Methods }
  100.  
  101. const
  102.   DispIDArgs: Longint = DISPID_PROPERTYPUT;
  103.  
  104. function HandleException: HResult;
  105. var
  106.   E: TObject;
  107. begin
  108.   E := ExceptObject;
  109.   if (E is EOleSysError) and (EOleSysError(E).ErrorCode < 0) then
  110.     Result := EOleSysError(E).ErrorCode else
  111.     Result := E_UNEXPECTED;
  112. end;
  113.  
  114. { GetDispatchPropValue returns the value of the property associated with }
  115. { Disp's DispID. }
  116. function GetDispatchPropValue(Disp: IDispatch; DispID: Integer): OleVariant;
  117. var
  118.   ExcepInfo: TExcepInfo;
  119.   DispParams: TDispParams;
  120.   Status: HResult;
  121. begin
  122.   FillChar(DispParams, SizeOf(DispParams), 0);
  123.   Status := Disp.Invoke(DispID, GUID_NULL, 0, DISPATCH_PROPERTYGET, DispParams,
  124.     @Result, @ExcepInfo, nil);
  125.   if Status <> S_OK then DispatchInvokeError(Status, ExcepInfo);
  126. end;
  127.  
  128. { SetDispatchPropValue sets the value of the property associated with }
  129. { Disp's DispID. }
  130. procedure SetDispatchPropValue(Disp: IDispatch; DispID: Integer;
  131.   const Value: OleVariant);
  132. var
  133.   ExcepInfo: TExcepInfo;
  134.   DispParams: TDispParams;
  135.   Status: HResult;
  136. begin
  137.   with DispParams do
  138.   begin
  139.     rgvarg := @Value;
  140.     rgdispidNamedArgs := @DispIDArgs;
  141.     cArgs := 1;
  142.     cNamedArgs := 1;
  143.   end;
  144.   Status := Disp.Invoke(DispId, GUID_NULL, 0, DISPATCH_PROPERTYPUT, DispParams,
  145.     nil, @ExcepInfo, nil);
  146.   if Status <> S_OK then DispatchInvokeError(Status, ExcepInfo);
  147. end;
  148.  
  149. { EnumDispatchProperties fills a TStrings with property names and }
  150. { dispids for the properties of Dispatch.  You can use PropType and }
  151. { VTCode to filter for properties of a specific type, or you can pass }
  152. { GUID_NULL and VT_EMPTY respectively to get all properties. }
  153. procedure EnumDispatchProperties(Dispatch: IDispatch; PropType: TGUID;
  154.   VTCode: Integer; PropList: TStrings);
  155. const
  156.   INVOKE_PROPERTYSET = INVOKE_PROPERTYPUT or INVOKE_PROPERTYPUTREF;
  157. var
  158.   I: Integer;
  159.   TypeInfo: ITypeInfo;
  160.   TypeAttr: PTypeAttr;
  161.   FuncDesc: PFuncDesc;
  162.   VarDesc: PVarDesc;
  163.  
  164.   procedure SaveName(Id: Integer);
  165.   var
  166.     Name: WideString;
  167.   begin
  168.     OleCheck(TypeInfo.GetDocumentation(Id, @Name, nil, nil, nil));
  169.     if PropList.IndexOfObject(TObject(Id)) = -1 then
  170.       PropList.AddObject(Name, TObject(Id));
  171.   end;
  172.  
  173.   function IsPropType(const TypeInfo: ITypeInfo; TypeDesc: PTypeDesc): Boolean;
  174.   var
  175.     RefInfo: ITypeInfo;
  176.     RefAttr: PTypeAttr;
  177.     IsNullGuid: Boolean;
  178.   begin
  179.     IsNullGuid := IsEqualGuid(PropType, GUID_NULL);
  180.     Result := IsNullGuid and (VTCode = VT_EMPTY);
  181.     if Result then Exit;
  182.     case TypeDesc.vt of
  183.       VT_PTR: Result := IsPropType(TypeInfo, TypeDesc.ptdesc);
  184.       VT_USERDEFINED:
  185.         begin
  186.           OleCheck(TypeInfo.GetRefTypeInfo(TypeDesc.hreftype, RefInfo));
  187.           OleCheck(RefInfo.GetTypeAttr(RefAttr));
  188.           try
  189.             Result := IsEqualGUID(RefAttr.guid, PropType);
  190.             if not Result and (RefAttr.typekind = TKIND_ALIAS) then
  191.               Result := IsPropType(RefInfo, @RefAttr.tdescAlias);
  192.           finally
  193.             RefInfo.ReleaseTypeAttr(RefAttr);
  194.           end;
  195.         end;
  196.     else
  197.       Result := IsNullGuid and (TypeDesc.vt = VTCode);
  198.     end;
  199.   end;
  200.  
  201.   function HasMember(const TypeInfo: ITypeInfo; Cnt, MemID, InvKind: Integer): Boolean;
  202.   var
  203.     I: Integer;
  204.     FuncDesc: PFuncDesc;
  205.   begin
  206.     for I := 0 to Cnt - 1 do
  207.     begin
  208.       OleCheck(TypeInfo.GetFuncDesc(I, FuncDesc));
  209.       try
  210.         if (FuncDesc.memid = MemID) and (FuncDesc.invkind and InvKind <> 0) then
  211.         begin
  212.           Result := True;
  213.           Exit;
  214.         end;
  215.       finally
  216.         TypeInfo.ReleaseFuncDesc(FuncDesc);
  217.       end;
  218.     end;
  219.     Result := False;
  220.   end;
  221.  
  222. begin
  223.   OleCheck(Dispatch.GetTypeInfo(0,0,TypeInfo));
  224.   if TypeInfo = nil then Exit;
  225.   OleCheck(TypeInfo.GetTypeAttr(TypeAttr));
  226.   try
  227.     for I := 0 to TypeAttr.cVars - 1 do
  228.     begin
  229.       OleCheck(TypeInfo.GetVarDesc(I, VarDesc));
  230.       try
  231.         if (VarDesc.wVarFlags and VARFLAG_FREADONLY <> 0) and
  232.           IsPropType(TypeInfo, @VarDesc.elemdescVar.tdesc) then
  233.           SaveName(VarDesc.memid);
  234.       finally
  235.         TypeInfo.ReleaseVarDesc(VarDesc);
  236.       end;
  237.     end;
  238.     for I := 0 to TypeAttr.cFuncs - 1 do
  239.     begin
  240.       OleCheck(TypeInfo.GetFuncDesc(I, FuncDesc));
  241.       try
  242.         if ((FuncDesc.invkind = INVOKE_PROPERTYGET) and
  243.           HasMember(TypeInfo, TypeAttr.cFuncs, FuncDesc.memid, INVOKE_PROPERTYSET) and
  244.           IsPropType(TypeInfo, @FuncDesc.elemdescFunc.tdesc)) or
  245.           ((FuncDesc.invkind and INVOKE_PROPERTYSET <> 0) and
  246.           HasMember(TypeInfo, TypeAttr.cFuncs, FuncDesc.memid, INVOKE_PROPERTYGET) and
  247.           IsPropType(TypeInfo,
  248.             @FuncDesc.lprgelemdescParam[FuncDesc.cParams - 1].tdesc)) then
  249.             SaveName(FuncDesc.memid);
  250.       finally
  251.         TypeInfo.ReleaseFuncDesc(FuncDesc);
  252.       end;
  253.     end;
  254.   finally
  255.     TypeInfo.ReleaseTypeAttr(TypeAttr);
  256.   end;
  257. end;
  258.  
  259. { TEditX }
  260.  
  261. { TEditX.IPersistPropertyBag }
  262.  
  263. function TEditX.PersistPropBagInitNew: HResult;
  264. begin
  265.   // NOTE: A return value of E_NOTIMPL is not allowed.  You must return S_OK
  266.   // even if this method does nothing.
  267.   Result := S_OK;
  268. end;
  269.  
  270. function TEditX.PersistPropBagLoad(const pPropBag: IPropertyBag;
  271.   const pErrorLog: IErrorLog): HResult;
  272. var
  273.   PropList: TStringList;
  274.   i: Integer;
  275.   WPropName: WideString;
  276.   PropValue: OleVariant;
  277. begin
  278.   try
  279.     if pPropBag = nil then
  280.     begin
  281.       Result := E_POINTER;
  282.       Exit;
  283.     end;
  284.     Result := S_OK;
  285.     PropList := TStringList.Create;
  286.     try
  287.       EnumDispatchProperties(Self as IDispatch, GUID_NULL, VT_EMPTY, PropList);
  288.       for i := 0 to PropList.Count - 1 do
  289.       begin
  290.         WPropName := PropList[i];
  291.         if pPropBag.Read(PWideChar(WPropName), PropValue, pErrorLog) = S_OK then
  292.           SetDispatchPropValue(Self as IDispatch, Integer(PropList.Objects[i]),
  293.             PropValue);
  294.       end;
  295.     finally
  296.       PropList.Free;
  297.     end;
  298.   except
  299.     Result := HandleException;
  300.   end;
  301. end;
  302.  
  303. function TEditX.PersistPropBagSave(const pPropBag: IPropertyBag;
  304.   fClearDirty: BOOL; fSaveAllProperties: BOOL): HResult;
  305. var
  306.   PropList: TStringList;
  307.   i: Integer;
  308.   WPropName: WideString;
  309. begin
  310.   try
  311.     if pPropBag = nil then
  312.     begin
  313.       Result := E_POINTER;
  314.       Exit;
  315.     end;
  316.     Result := S_OK;
  317.     PropList := TStringList.Create;
  318.     try
  319.       EnumDispatchProperties(Self as IDispatch, GUID_NULL, VT_EMPTY, PropList);
  320.       for i := 0 to PropList.Count - 1 do
  321.       begin
  322.         WPropName := PropList[i];
  323.         pPropBag.Write(PWideChar(WPropName),
  324.           GetDispatchPropValue(Self as IDispatch, Integer(PropList.Objects[i])));
  325.       end;
  326.     finally
  327.       PropList.Free;
  328.     end;
  329.   except
  330.     Result := HandleException;
  331.   end;
  332. end;
  333.  
  334. { TEditX Delphi-generated methods }
  335.  
  336. procedure TEditX.InitializeControl;
  337. begin
  338.   FDelphiControl := Control as TEdit;
  339.   FDelphiControl.OnChange := ChangeEvent;
  340.   FDelphiControl.OnClick := ClickEvent;
  341.   FDelphiControl.OnDblClick := DblClickEvent;
  342.   FDelphiControl.OnKeyPress := KeyPressEvent;
  343. end;
  344.  
  345. procedure TEditX.EventSinkChanged(const EventSink: IUnknown);
  346. begin
  347.   FEvents := EventSink as IEditXEvents;
  348. end;
  349.  
  350. procedure TEditX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  351. begin
  352.   { Define property pages here.  Property pages are defined by calling
  353.     DefinePropertyPage with the class id of the page.  For example,
  354.       DefinePropertyPage(Class_EditXPage); }
  355. end;
  356.  
  357. function TEditX.Get_AutoSelect: WordBool;
  358. begin
  359.   Result := FDelphiControl.AutoSelect;
  360. end;
  361.  
  362. function TEditX.Get_AutoSize: WordBool;
  363. begin
  364.   Result := FDelphiControl.AutoSize;
  365. end;
  366.  
  367. function TEditX.Get_BorderStyle: TxBorderStyle;
  368. begin
  369.   Result := Ord(FDelphiControl.BorderStyle);
  370. end;
  371.  
  372. function TEditX.Get_CharCase: TxEditCharCase;
  373. begin
  374.   Result := Ord(FDelphiControl.CharCase);
  375. end;
  376.  
  377. function TEditX.Get_Color: TColor;
  378. begin
  379.   Result := FDelphiControl.Color;
  380. end;
  381.  
  382. function TEditX.Get_Ctl3D: WordBool;
  383. begin
  384.   Result := FDelphiControl.Ctl3D;
  385. end;
  386.  
  387. function TEditX.Get_Cursor: Smallint;
  388. begin
  389.   Result := Smallint(FDelphiControl.Cursor);
  390. end;
  391.  
  392. function TEditX.Get_DragCursor: Smallint;
  393. begin
  394.   Result := Smallint(FDelphiControl.DragCursor);
  395. end;
  396.  
  397. function TEditX.Get_DragMode: TxDragMode;
  398. begin
  399.   Result := Ord(FDelphiControl.DragMode);
  400. end;
  401.  
  402. function TEditX.Get_Enabled: WordBool;
  403. begin
  404.   Result := FDelphiControl.Enabled;
  405. end;
  406.  
  407. function TEditX.Get_Font: Font;
  408. begin
  409.   GetOleFont(FDelphiControl.Font, Result);
  410. end;
  411.  
  412. function TEditX.Get_HideSelection: WordBool;
  413. begin
  414.   Result := FDelphiControl.HideSelection;
  415. end;
  416.  
  417. function TEditX.Get_ImeMode: TxImeMode;
  418. begin
  419.   Result := Ord(FDelphiControl.ImeMode);
  420. end;
  421.  
  422. function TEditX.Get_ImeName: WideString;
  423. begin
  424.   Result := WideString(FDelphiControl.ImeName);
  425. end;
  426.  
  427. function TEditX.Get_MaxLength: Integer;
  428. begin
  429.   Result := FDelphiControl.MaxLength;
  430. end;
  431.  
  432. function TEditX.Get_Modified: WordBool;
  433. begin
  434.   Result := FDelphiControl.Modified;
  435. end;
  436.  
  437. function TEditX.Get_OEMConvert: WordBool;
  438. begin
  439.   Result := FDelphiControl.OEMConvert;
  440. end;
  441.  
  442. function TEditX.Get_ParentColor: WordBool;
  443. begin
  444.   Result := FDelphiControl.ParentColor;
  445. end;
  446.  
  447. function TEditX.Get_ParentCtl3D: WordBool;
  448. begin
  449.   Result := FDelphiControl.ParentCtl3D;
  450. end;
  451.  
  452. function TEditX.Get_PasswordChar: Smallint;
  453. begin
  454.   Result := Smallint(FDelphiControl.PasswordChar);
  455. end;
  456.  
  457. function TEditX.Get_ReadOnly: WordBool;
  458. begin
  459.   Result := FDelphiControl.ReadOnly;
  460. end;
  461.  
  462. function TEditX.Get_SelLength: Integer;
  463. begin
  464.   Result := FDelphiControl.SelLength;
  465. end;
  466.  
  467. function TEditX.Get_SelStart: Integer;
  468. begin
  469.   Result := FDelphiControl.SelStart;
  470. end;
  471.  
  472. function TEditX.Get_SelText: WideString;
  473. begin
  474.   Result := WideString(FDelphiControl.SelText);
  475. end;
  476.  
  477. function TEditX.Get_Text: WideString;
  478. begin
  479.   Result := WideString(FDelphiControl.Text);
  480. end;
  481.  
  482. function TEditX.Get_Visible: WordBool;
  483. begin
  484.   Result := FDelphiControl.Visible;
  485. end;
  486.  
  487. procedure TEditX.AboutBox;
  488. begin
  489.   ShowEditXAbout;
  490. end;
  491.  
  492. procedure TEditX.Clear;
  493. begin
  494.  
  495. end;
  496.  
  497. procedure TEditX.ClearSelection;
  498. begin
  499.  
  500. end;
  501.  
  502. procedure TEditX.CopyToClipboard;
  503. begin
  504.  
  505. end;
  506.  
  507. procedure TEditX.CutToClipboard;
  508. begin
  509.  
  510. end;
  511.  
  512. procedure TEditX.PasteFromClipboard;
  513. begin
  514.  
  515. end;
  516.  
  517. procedure TEditX.SelectAll;
  518. begin
  519.  
  520. end;
  521.  
  522. procedure TEditX.Set_AutoSelect(Value: WordBool);
  523. begin
  524.   FDelphiControl.AutoSelect := Value;
  525. end;
  526.  
  527. procedure TEditX.Set_AutoSize(Value: WordBool);
  528. begin
  529.   FDelphiControl.AutoSize := Value;
  530. end;
  531.  
  532. procedure TEditX.Set_BorderStyle(Value: TxBorderStyle);
  533. begin
  534.   FDelphiControl.BorderStyle := TBorderStyle(Value);
  535. end;
  536.  
  537. procedure TEditX.Set_CharCase(Value: TxEditCharCase);
  538. begin
  539.   FDelphiControl.CharCase := TEditCharCase(Value);
  540. end;
  541.  
  542. procedure TEditX.Set_Color(Value: TColor);
  543. begin
  544.   FDelphiControl.Color := Value;
  545. end;
  546.  
  547. procedure TEditX.Set_Ctl3D(Value: WordBool);
  548. begin
  549.   FDelphiControl.Ctl3D := Value;
  550. end;
  551.  
  552. procedure TEditX.Set_Cursor(Value: Smallint);
  553. begin
  554.   FDelphiControl.Cursor := TCursor(Value);
  555. end;
  556.  
  557. procedure TEditX.Set_DragCursor(Value: Smallint);
  558. begin
  559.   FDelphiControl.DragCursor := TCursor(Value);
  560. end;
  561.  
  562. procedure TEditX.Set_DragMode(Value: TxDragMode);
  563. begin
  564.   FDelphiControl.DragMode := TDragMode(Value);
  565. end;
  566.  
  567. procedure TEditX.Set_Enabled(Value: WordBool);
  568. begin
  569.   FDelphiControl.Enabled := Value;
  570. end;
  571.  
  572. procedure TEditX.Set_Font(const Value: Font);
  573. begin
  574.   SetOleFont(FDelphiControl.Font, Value);
  575. end;
  576.  
  577. procedure TEditX.Set_HideSelection(Value: WordBool);
  578. begin
  579.   FDelphiControl.HideSelection := Value;
  580. end;
  581.  
  582. procedure TEditX.Set_ImeMode(Value: TxImeMode);
  583. begin
  584.   FDelphiControl.ImeMode := TImeMode(Value);
  585. end;
  586.  
  587. procedure TEditX.Set_ImeName(const Value: WideString);
  588. begin
  589.   FDelphiControl.ImeName := TImeName(Value);
  590. end;
  591.  
  592. procedure TEditX.Set_MaxLength(Value: Integer);
  593. begin
  594.   FDelphiControl.MaxLength := Value;
  595. end;
  596.  
  597. procedure TEditX.Set_Modified(Value: WordBool);
  598. begin
  599.   FDelphiControl.Modified := Value;
  600. end;
  601.  
  602. procedure TEditX.Set_OEMConvert(Value: WordBool);
  603. begin
  604.   FDelphiControl.OEMConvert := Value;
  605. end;
  606.  
  607. procedure TEditX.Set_ParentColor(Value: WordBool);
  608. begin
  609.   FDelphiControl.ParentColor := Value;
  610. end;
  611.  
  612. procedure TEditX.Set_ParentCtl3D(Value: WordBool);
  613. begin
  614.   FDelphiControl.ParentCtl3D := Value;
  615. end;
  616.  
  617. procedure TEditX.Set_PasswordChar(Value: Smallint);
  618. begin
  619.   FDelphiControl.PasswordChar := Char(Value);
  620. end;
  621.  
  622. procedure TEditX.Set_ReadOnly(Value: WordBool);
  623. begin
  624.   FDelphiControl.ReadOnly := Value;
  625. end;
  626.  
  627. procedure TEditX.Set_SelLength(Value: Integer);
  628. begin
  629.   FDelphiControl.SelLength := Value;
  630. end;
  631.  
  632. procedure TEditX.Set_SelStart(Value: Integer);
  633. begin
  634.   FDelphiControl.SelStart := Value;
  635. end;
  636.  
  637. procedure TEditX.Set_SelText(const Value: WideString);
  638. begin
  639.   FDelphiControl.SelText := String(Value);
  640. end;
  641.  
  642. procedure TEditX.Set_Text(const Value: WideString);
  643. begin
  644.   FDelphiControl.Text := TCaption(Value);
  645. end;
  646.  
  647. procedure TEditX.Set_Visible(Value: WordBool);
  648. begin
  649.   FDelphiControl.Visible := Value;
  650. end;
  651.  
  652. procedure TEditX.ChangeEvent(Sender: TObject);
  653. begin
  654.   if FEvents <> nil then FEvents.OnChange;
  655. end;
  656.  
  657. procedure TEditX.ClickEvent(Sender: TObject);
  658. begin
  659.   if FEvents <> nil then FEvents.OnClick;
  660. end;
  661.  
  662. procedure TEditX.DblClickEvent(Sender: TObject);
  663. begin
  664.   if FEvents <> nil then FEvents.OnDblClick;
  665. end;
  666.  
  667. procedure TEditX.KeyPressEvent(Sender: TObject; var Key: Char);
  668. var
  669.   TempKey: Smallint;
  670. begin
  671.   TempKey := Smallint(Key);
  672.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  673.   Key := Char(TempKey);
  674. end;
  675.  
  676. initialization
  677.   TActiveXControlFactory.Create(
  678.     ComServer,
  679.     TEditX,
  680.     TEdit,
  681.     Class_EditX,
  682.     1,
  683.     '',
  684.     0);
  685. end.
  686.