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

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