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

  1. unit ChkBImpl;
  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.   TCheckBoxX = class(TActiveXControl, ICheckBoxX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TCheckBox;
  14.     FEvents: ICheckBoxXEvents;
  15.     procedure ClickEvent(Sender: TObject);
  16.     procedure KeyPressEvent(Sender: TObject; var Key: Char);
  17.   protected
  18.     { Protected declarations }
  19.     procedure InitializeControl; override;
  20.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  21.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  22.     function Get_Alignment: TxLeftRight; safecall;
  23.     function Get_AllowGrayed: WordBool; safecall;
  24.     function Get_Caption: WideString; safecall;
  25.     function Get_Checked: 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_Enabled: WordBool; safecall;
  32.     function Get_Font: Font; safecall;
  33.     function Get_ParentColor: WordBool; safecall;
  34.     function Get_ParentCtl3D: WordBool; safecall;
  35.     function Get_State: TxCheckBoxState; safecall;
  36.     function Get_Visible: WordBool; safecall;
  37.     procedure AboutBox; safecall;
  38.     procedure Set_Alignment(Value: TxLeftRight); safecall;
  39.     procedure Set_AllowGrayed(Value: WordBool); safecall;
  40.     procedure Set_Caption(const Value: WideString); safecall;
  41.     procedure Set_Checked(Value: WordBool); safecall;
  42.     procedure Set_Color(Value: TColor); safecall;
  43.     procedure Set_Ctl3D(Value: WordBool); safecall;
  44.     procedure Set_Cursor(Value: Smallint); safecall;
  45.     procedure Set_DragCursor(Value: Smallint); safecall;
  46.     procedure Set_DragMode(Value: TxDragMode); safecall;
  47.     procedure Set_Enabled(Value: WordBool); safecall;
  48.     procedure Set_Font(const Value: Font); safecall;
  49.     procedure Set_ParentColor(Value: WordBool); safecall;
  50.     procedure Set_ParentCtl3D(Value: WordBool); safecall;
  51.     procedure Set_State(Value: TxCheckBoxState); safecall;
  52.     procedure Set_Visible(Value: WordBool); safecall;
  53.   end;
  54.  
  55. implementation
  56.  
  57. uses About4;
  58.  
  59. { TCheckBoxX }
  60.  
  61. procedure TCheckBoxX.InitializeControl;
  62. begin
  63.   FDelphiControl := Control as TCheckBox;
  64.   FDelphiControl.OnClick := ClickEvent;
  65.   FDelphiControl.OnKeyPress := KeyPressEvent;
  66. end;
  67.  
  68. procedure TCheckBoxX.EventSinkChanged(const EventSink: IUnknown);
  69. begin
  70.   FEvents := EventSink as ICheckBoxXEvents;
  71. end;
  72.  
  73. procedure TCheckBoxX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  74. begin
  75.   { Define property pages here.  Property pages are defined by calling
  76.     DefinePropertyPage with the class id of the page.  For example,
  77.       DefinePropertyPage(Class_CheckBoxXPage); }
  78. end;
  79.  
  80. function TCheckBoxX.Get_Alignment: TxLeftRight;
  81. begin
  82.   Result := Ord(FDelphiControl.Alignment);
  83. end;
  84.  
  85. function TCheckBoxX.Get_AllowGrayed: WordBool;
  86. begin
  87.   Result := FDelphiControl.AllowGrayed;
  88. end;
  89.  
  90. function TCheckBoxX.Get_Caption: WideString;
  91. begin
  92.   Result := WideString(FDelphiControl.Caption);
  93. end;
  94.  
  95. function TCheckBoxX.Get_Checked: WordBool;
  96. begin
  97.   Result := FDelphiControl.Checked;
  98. end;
  99.  
  100. function TCheckBoxX.Get_Color: TColor;
  101. begin
  102.   Result := FDelphiControl.Color;
  103. end;
  104.  
  105. function TCheckBoxX.Get_Ctl3D: WordBool;
  106. begin
  107.   Result := FDelphiControl.Ctl3D;
  108. end;
  109.  
  110. function TCheckBoxX.Get_Cursor: Smallint;
  111. begin
  112.   Result := Smallint(FDelphiControl.Cursor);
  113. end;
  114.  
  115. function TCheckBoxX.Get_DragCursor: Smallint;
  116. begin
  117.   Result := Smallint(FDelphiControl.DragCursor);
  118. end;
  119.  
  120. function TCheckBoxX.Get_DragMode: TxDragMode;
  121. begin
  122.   Result := Ord(FDelphiControl.DragMode);
  123. end;
  124.  
  125. function TCheckBoxX.Get_Enabled: WordBool;
  126. begin
  127.   Result := FDelphiControl.Enabled;
  128. end;
  129.  
  130. function TCheckBoxX.Get_Font: Font;
  131. begin
  132.   GetOleFont(FDelphiControl.Font, Result);
  133. end;
  134.  
  135. function TCheckBoxX.Get_ParentColor: WordBool;
  136. begin
  137.   Result := FDelphiControl.ParentColor;
  138. end;
  139.  
  140. function TCheckBoxX.Get_ParentCtl3D: WordBool;
  141. begin
  142.   Result := FDelphiControl.ParentCtl3D;
  143. end;
  144.  
  145. function TCheckBoxX.Get_State: TxCheckBoxState;
  146. begin
  147.   Result := Ord(FDelphiControl.State);
  148. end;
  149.  
  150. function TCheckBoxX.Get_Visible: WordBool;
  151. begin
  152.   Result := FDelphiControl.Visible;
  153. end;
  154.  
  155. procedure TCheckBoxX.AboutBox;
  156. begin
  157.   ShowCheckBoxXAbout;
  158. end;
  159.  
  160. procedure TCheckBoxX.Set_Alignment(Value: TxLeftRight);
  161. begin
  162.   FDelphiControl.Alignment := TLeftRight(Value);
  163. end;
  164.  
  165. procedure TCheckBoxX.Set_AllowGrayed(Value: WordBool);
  166. begin
  167.   FDelphiControl.AllowGrayed := Value;
  168. end;
  169.  
  170. procedure TCheckBoxX.Set_Caption(const Value: WideString);
  171. begin
  172.   FDelphiControl.Caption := TCaption(Value);
  173. end;
  174.  
  175. procedure TCheckBoxX.Set_Checked(Value: WordBool);
  176. begin
  177.   FDelphiControl.Checked := Value;
  178. end;
  179.  
  180. procedure TCheckBoxX.Set_Color(Value: TColor);
  181. begin
  182.   FDelphiControl.Color := Value;
  183. end;
  184.  
  185. procedure TCheckBoxX.Set_Ctl3D(Value: WordBool);
  186. begin
  187.   FDelphiControl.Ctl3D := Value;
  188. end;
  189.  
  190. procedure TCheckBoxX.Set_Cursor(Value: Smallint);
  191. begin
  192.   FDelphiControl.Cursor := TCursor(Value);
  193. end;
  194.  
  195. procedure TCheckBoxX.Set_DragCursor(Value: Smallint);
  196. begin
  197.   FDelphiControl.DragCursor := TCursor(Value);
  198. end;
  199.  
  200. procedure TCheckBoxX.Set_DragMode(Value: TxDragMode);
  201. begin
  202.   FDelphiControl.DragMode := TDragMode(Value);
  203. end;
  204.  
  205. procedure TCheckBoxX.Set_Enabled(Value: WordBool);
  206. begin
  207.   FDelphiControl.Enabled := Value;
  208. end;
  209.  
  210. procedure TCheckBoxX.Set_Font(const Value: Font);
  211. begin
  212.   SetOleFont(FDelphiControl.Font, Value);
  213. end;
  214.  
  215. procedure TCheckBoxX.Set_ParentColor(Value: WordBool);
  216. begin
  217.   FDelphiControl.ParentColor := Value;
  218. end;
  219.  
  220. procedure TCheckBoxX.Set_ParentCtl3D(Value: WordBool);
  221. begin
  222.   FDelphiControl.ParentCtl3D := Value;
  223. end;
  224.  
  225. procedure TCheckBoxX.Set_State(Value: TxCheckBoxState);
  226. begin
  227.   FDelphiControl.State := TCheckBoxState(Value);
  228. end;
  229.  
  230. procedure TCheckBoxX.Set_Visible(Value: WordBool);
  231. begin
  232.   FDelphiControl.Visible := Value;
  233. end;
  234.  
  235. procedure TCheckBoxX.ClickEvent(Sender: TObject);
  236. begin
  237.   if FEvents <> nil then FEvents.OnClick;
  238. end;
  239.  
  240. procedure TCheckBoxX.KeyPressEvent(Sender: TObject; var Key: Char);
  241. var
  242.   TempKey: Smallint;
  243. begin
  244.   TempKey := Smallint(Key);
  245.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  246.   Key := Char(TempKey);
  247. end;
  248.  
  249. initialization
  250.   TActiveXControlFactory.Create(
  251.     ComServer,
  252.     TCheckBoxX,
  253.     TCheckBox,
  254.     Class_CheckBoxX,
  255.     4,
  256.     '{FA7B82FE-9ED7-11D0-AA40-444553540000}',
  257.     0);
  258. end.
  259.