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

  1. unit MemoImpl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelC_TLB;
  8.  
  9. type
  10.   TMemoX = class(TActiveXControl, IMemoX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TMemo;
  14.     FEvents: IMemoXEvents;
  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.     { Protected declarations }
  21.     procedure InitializeControl; override;
  22.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  23.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  24.     function Get_Alignment: TxAlignment; safecall;
  25.     function Get_BorderStyle: TxBorderStyle; safecall;
  26.     function Get_Color: TColor; safecall;
  27.     function Get_Ctl3D: WordBool; safecall;
  28.     function Get_Cursor: Smallint; safecall;
  29.     function Get_DragCursor: Smallint; safecall;
  30.     function Get_DragMode: TxDragMode; safecall;
  31.     function Get_Enabled: WordBool; safecall;
  32.     function Get_Font: Font; safecall;
  33.     function Get_HideSelection: WordBool; safecall;
  34.     function Get_ImeMode: TxImeMode; safecall;
  35.     function Get_ImeName: WideString; safecall;
  36.     function Get_Lines: IStrings; safecall;
  37.     function Get_MaxLength: Integer; safecall;
  38.     function Get_Modified: WordBool; safecall;
  39.     function Get_OEMConvert: WordBool; safecall;
  40.     function Get_ParentColor: WordBool; safecall;
  41.     function Get_ParentCtl3D: WordBool; safecall;
  42.     function Get_ReadOnly: WordBool; safecall;
  43.     function Get_ScrollBars: TxScrollStyle; safecall;
  44.     function Get_SelLength: Integer; safecall;
  45.     function Get_SelStart: Integer; safecall;
  46.     function Get_SelText: WideString; safecall;
  47.     function Get_Text: WideString; safecall;
  48.     function Get_Visible: WordBool; safecall;
  49.     function Get_WantReturns: WordBool; safecall;
  50.     function Get_WantTabs: WordBool; safecall;
  51.     function Get_WordWrap: WordBool; safecall;
  52.     procedure AboutBox; safecall;
  53.     procedure Clear; safecall;
  54.     procedure ClearSelection; safecall;
  55.     procedure CopyToClipboard; safecall;
  56.     procedure CutToClipboard; safecall;
  57.     procedure PasteFromClipboard; safecall;
  58.     procedure SelectAll; safecall;
  59.     procedure Set_Alignment(Value: TxAlignment); safecall;
  60.     procedure Set_BorderStyle(Value: TxBorderStyle); safecall;
  61.     procedure Set_Color(Value: TColor); safecall;
  62.     procedure Set_Ctl3D(Value: WordBool); safecall;
  63.     procedure Set_Cursor(Value: Smallint); safecall;
  64.     procedure Set_DragCursor(Value: Smallint); safecall;
  65.     procedure Set_DragMode(Value: TxDragMode); safecall;
  66.     procedure Set_Enabled(Value: WordBool); safecall;
  67.     procedure Set_Font(const Value: Font); safecall;
  68.     procedure Set_HideSelection(Value: WordBool); safecall;
  69.     procedure Set_ImeMode(Value: TxImeMode); safecall;
  70.     procedure Set_ImeName(const Value: WideString); safecall;
  71.     procedure Set_Lines(const Value: IStrings); safecall;
  72.     procedure Set_MaxLength(Value: Integer); safecall;
  73.     procedure Set_Modified(Value: WordBool); safecall;
  74.     procedure Set_OEMConvert(Value: WordBool); safecall;
  75.     procedure Set_ParentColor(Value: WordBool); safecall;
  76.     procedure Set_ParentCtl3D(Value: WordBool); safecall;
  77.     procedure Set_ReadOnly(Value: WordBool); safecall;
  78.     procedure Set_ScrollBars(Value: TxScrollStyle); safecall;
  79.     procedure Set_SelLength(Value: Integer); safecall;
  80.     procedure Set_SelStart(Value: Integer); safecall;
  81.     procedure Set_SelText(const Value: WideString); safecall;
  82.     procedure Set_Text(const Value: WideString); safecall;
  83.     procedure Set_Visible(Value: WordBool); safecall;
  84.     procedure Set_WantReturns(Value: WordBool); safecall;
  85.     procedure Set_WantTabs(Value: WordBool); safecall;
  86.     procedure Set_WordWrap(Value: WordBool); safecall;
  87.   end;
  88.  
  89. implementation
  90.  
  91. uses About16;
  92.  
  93. { TMemoX }
  94.  
  95. procedure TMemoX.InitializeControl;
  96. begin
  97.   FDelphiControl := Control as TMemo;
  98.   FDelphiControl.OnChange := ChangeEvent;
  99.   FDelphiControl.OnClick := ClickEvent;
  100.   FDelphiControl.OnDblClick := DblClickEvent;
  101.   FDelphiControl.OnKeyPress := KeyPressEvent;
  102. end;
  103.  
  104. procedure TMemoX.EventSinkChanged(const EventSink: IUnknown);
  105. begin
  106.   FEvents := EventSink as IMemoXEvents;
  107. end;
  108.  
  109. procedure TMemoX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  110. begin
  111.   { Define property pages here.  Property pages are defined by calling
  112.     DefinePropertyPage with the class id of the page.  For example,
  113.       DefinePropertyPage(Class_MemoXPage); }
  114. end;
  115.  
  116. function TMemoX.Get_Alignment: TxAlignment;
  117. begin
  118.   Result := Ord(FDelphiControl.Alignment);
  119. end;
  120.  
  121. function TMemoX.Get_BorderStyle: TxBorderStyle;
  122. begin
  123.   Result := Ord(FDelphiControl.BorderStyle);
  124. end;
  125.  
  126. function TMemoX.Get_Color: TColor;
  127. begin
  128.   Result := FDelphiControl.Color;
  129. end;
  130.  
  131. function TMemoX.Get_Ctl3D: WordBool;
  132. begin
  133.   Result := FDelphiControl.Ctl3D;
  134. end;
  135.  
  136. function TMemoX.Get_Cursor: Smallint;
  137. begin
  138.   Result := Smallint(FDelphiControl.Cursor);
  139. end;
  140.  
  141. function TMemoX.Get_DragCursor: Smallint;
  142. begin
  143.   Result := Smallint(FDelphiControl.DragCursor);
  144. end;
  145.  
  146. function TMemoX.Get_DragMode: TxDragMode;
  147. begin
  148.   Result := Ord(FDelphiControl.DragMode);
  149. end;
  150.  
  151. function TMemoX.Get_Enabled: WordBool;
  152. begin
  153.   Result := FDelphiControl.Enabled;
  154. end;
  155.  
  156. function TMemoX.Get_Font: Font;
  157. begin
  158.   GetOleFont(FDelphiControl.Font, Result);
  159. end;
  160.  
  161. function TMemoX.Get_HideSelection: WordBool;
  162. begin
  163.   Result := FDelphiControl.HideSelection;
  164. end;
  165.  
  166. function TMemoX.Get_ImeMode: TxImeMode;
  167. begin
  168.   Result := Ord(FDelphiControl.ImeMode);
  169. end;
  170.  
  171. function TMemoX.Get_ImeName: WideString;
  172. begin
  173.   Result := WideString(FDelphiControl.ImeName);
  174. end;
  175.  
  176. function TMemoX.Get_Lines: IStrings;
  177. begin
  178.   GetOleStrings(FDelphiControl.Lines, Result);
  179. end;
  180.  
  181. function TMemoX.Get_MaxLength: Integer;
  182. begin
  183.   Result := FDelphiControl.MaxLength;
  184. end;
  185.  
  186. function TMemoX.Get_Modified: WordBool;
  187. begin
  188.   Result := FDelphiControl.Modified;
  189. end;
  190.  
  191. function TMemoX.Get_OEMConvert: WordBool;
  192. begin
  193.   Result := FDelphiControl.OEMConvert;
  194. end;
  195.  
  196. function TMemoX.Get_ParentColor: WordBool;
  197. begin
  198.   Result := FDelphiControl.ParentColor;
  199. end;
  200.  
  201. function TMemoX.Get_ParentCtl3D: WordBool;
  202. begin
  203.   Result := FDelphiControl.ParentCtl3D;
  204. end;
  205.  
  206. function TMemoX.Get_ReadOnly: WordBool;
  207. begin
  208.   Result := FDelphiControl.ReadOnly;
  209. end;
  210.  
  211. function TMemoX.Get_ScrollBars: TxScrollStyle;
  212. begin
  213.   Result := Ord(FDelphiControl.ScrollBars);
  214. end;
  215.  
  216. function TMemoX.Get_SelLength: Integer;
  217. begin
  218.   Result := FDelphiControl.SelLength;
  219. end;
  220.  
  221. function TMemoX.Get_SelStart: Integer;
  222. begin
  223.   Result := FDelphiControl.SelStart;
  224. end;
  225.  
  226. function TMemoX.Get_SelText: WideString;
  227. begin
  228.   Result := WideString(FDelphiControl.SelText);
  229. end;
  230.  
  231. function TMemoX.Get_Text: WideString;
  232. begin
  233.   Result := WideString(FDelphiControl.Text);
  234. end;
  235.  
  236. function TMemoX.Get_Visible: WordBool;
  237. begin
  238.   Result := FDelphiControl.Visible;
  239. end;
  240.  
  241. function TMemoX.Get_WantReturns: WordBool;
  242. begin
  243.   Result := FDelphiControl.WantReturns;
  244. end;
  245.  
  246. function TMemoX.Get_WantTabs: WordBool;
  247. begin
  248.   Result := FDelphiControl.WantTabs;
  249. end;
  250.  
  251. function TMemoX.Get_WordWrap: WordBool;
  252. begin
  253.   Result := FDelphiControl.WordWrap;
  254. end;
  255.  
  256. procedure TMemoX.AboutBox;
  257. begin
  258.   ShowMemoXAbout;
  259. end;
  260.  
  261. procedure TMemoX.Clear;
  262. begin
  263.  
  264. end;
  265.  
  266. procedure TMemoX.ClearSelection;
  267. begin
  268.  
  269. end;
  270.  
  271. procedure TMemoX.CopyToClipboard;
  272. begin
  273.  
  274. end;
  275.  
  276. procedure TMemoX.CutToClipboard;
  277. begin
  278.  
  279. end;
  280.  
  281. procedure TMemoX.PasteFromClipboard;
  282. begin
  283.  
  284. end;
  285.  
  286. procedure TMemoX.SelectAll;
  287. begin
  288.  
  289. end;
  290.  
  291. procedure TMemoX.Set_Alignment(Value: TxAlignment);
  292. begin
  293.   FDelphiControl.Alignment := TAlignment(Value);
  294. end;
  295.  
  296. procedure TMemoX.Set_BorderStyle(Value: TxBorderStyle);
  297. begin
  298.   FDelphiControl.BorderStyle := TBorderStyle(Value);
  299. end;
  300.  
  301. procedure TMemoX.Set_Color(Value: TColor);
  302. begin
  303.   FDelphiControl.Color := Value;
  304. end;
  305.  
  306. procedure TMemoX.Set_Ctl3D(Value: WordBool);
  307. begin
  308.   FDelphiControl.Ctl3D := Value;
  309. end;
  310.  
  311. procedure TMemoX.Set_Cursor(Value: Smallint);
  312. begin
  313.   FDelphiControl.Cursor := TCursor(Value);
  314. end;
  315.  
  316. procedure TMemoX.Set_DragCursor(Value: Smallint);
  317. begin
  318.   FDelphiControl.DragCursor := TCursor(Value);
  319. end;
  320.  
  321. procedure TMemoX.Set_DragMode(Value: TxDragMode);
  322. begin
  323.   FDelphiControl.DragMode := TDragMode(Value);
  324. end;
  325.  
  326. procedure TMemoX.Set_Enabled(Value: WordBool);
  327. begin
  328.   FDelphiControl.Enabled := Value;
  329. end;
  330.  
  331. procedure TMemoX.Set_Font(const Value: Font);
  332. begin
  333.   SetOleFont(FDelphiControl.Font, Value);
  334. end;
  335.  
  336. procedure TMemoX.Set_HideSelection(Value: WordBool);
  337. begin
  338.   FDelphiControl.HideSelection := Value;
  339. end;
  340.  
  341. procedure TMemoX.Set_ImeMode(Value: TxImeMode);
  342. begin
  343.   FDelphiControl.ImeMode := TImeMode(Value);
  344. end;
  345.  
  346. procedure TMemoX.Set_ImeName(const Value: WideString);
  347. begin
  348.   FDelphiControl.ImeName := TImeName(Value);
  349. end;
  350.  
  351. procedure TMemoX.Set_Lines(const Value: IStrings);
  352. begin
  353.   SetOleStrings(FDelphiControl.Lines, Value);
  354. end;
  355.  
  356. procedure TMemoX.Set_MaxLength(Value: Integer);
  357. begin
  358.   FDelphiControl.MaxLength := Value;
  359. end;
  360.  
  361. procedure TMemoX.Set_Modified(Value: WordBool);
  362. begin
  363.   FDelphiControl.Modified := Value;
  364. end;
  365.  
  366. procedure TMemoX.Set_OEMConvert(Value: WordBool);
  367. begin
  368.   FDelphiControl.OEMConvert := Value;
  369. end;
  370.  
  371. procedure TMemoX.Set_ParentColor(Value: WordBool);
  372. begin
  373.   FDelphiControl.ParentColor := Value;
  374. end;
  375.  
  376. procedure TMemoX.Set_ParentCtl3D(Value: WordBool);
  377. begin
  378.   FDelphiControl.ParentCtl3D := Value;
  379. end;
  380.  
  381. procedure TMemoX.Set_ReadOnly(Value: WordBool);
  382. begin
  383.   FDelphiControl.ReadOnly := Value;
  384. end;
  385.  
  386. procedure TMemoX.Set_ScrollBars(Value: TxScrollStyle);
  387. begin
  388.   FDelphiControl.ScrollBars := TScrollStyle(Value);
  389. end;
  390.  
  391. procedure TMemoX.Set_SelLength(Value: Integer);
  392. begin
  393.   FDelphiControl.SelLength := Value;
  394. end;
  395.  
  396. procedure TMemoX.Set_SelStart(Value: Integer);
  397. begin
  398.   FDelphiControl.SelStart := Value;
  399. end;
  400.  
  401. procedure TMemoX.Set_SelText(const Value: WideString);
  402. begin
  403.   FDelphiControl.SelText := String(Value);
  404. end;
  405.  
  406. procedure TMemoX.Set_Text(const Value: WideString);
  407. begin
  408.   FDelphiControl.Text := TCaption(Value);
  409. end;
  410.  
  411. procedure TMemoX.Set_Visible(Value: WordBool);
  412. begin
  413.   FDelphiControl.Visible := Value;
  414. end;
  415.  
  416. procedure TMemoX.Set_WantReturns(Value: WordBool);
  417. begin
  418.   FDelphiControl.WantReturns := Value;
  419. end;
  420.  
  421. procedure TMemoX.Set_WantTabs(Value: WordBool);
  422. begin
  423.   FDelphiControl.WantTabs := Value;
  424. end;
  425.  
  426. procedure TMemoX.Set_WordWrap(Value: WordBool);
  427. begin
  428.   FDelphiControl.WordWrap := Value;
  429. end;
  430.  
  431. procedure TMemoX.ChangeEvent(Sender: TObject);
  432. begin
  433.   if FEvents <> nil then FEvents.OnChange;
  434. end;
  435.  
  436. procedure TMemoX.ClickEvent(Sender: TObject);
  437. begin
  438.   if FEvents <> nil then FEvents.OnClick;
  439. end;
  440.  
  441. procedure TMemoX.DblClickEvent(Sender: TObject);
  442. begin
  443.   if FEvents <> nil then FEvents.OnDblClick;
  444. end;
  445.  
  446. procedure TMemoX.KeyPressEvent(Sender: TObject; var Key: Char);
  447. var
  448.   TempKey: Smallint;
  449. begin
  450.   TempKey := Smallint(Key);
  451.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  452.   Key := Char(TempKey);
  453. end;
  454.  
  455. initialization
  456.   TActiveXControlFactory.Create(
  457.     ComServer,
  458.     TMemoX,
  459.     TMemo,
  460.     Class_MemoX,
  461.     16,
  462.     '{FA7B842E-9ED7-11D0-AA40-444553540000}',
  463.     0);
  464. end.
  465.