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

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