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

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