home *** CD-ROM | disk | FTP | other *** search
/ PC Expert 29 / Pce29cd.iso / RUNIMAGE / DELPHI40 / DEMOS / ACTIVEX / DELCTRLS / radiobuttonimpl1.pas < prev    next >
Pascal/Delphi Source File  |  1998-06-16  |  10KB  |  345 lines

  1. unit RadioButtonImpl1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelCtrls_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 DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  21.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  22.     procedure InitializeControl; override;
  23.     function ClassNameIs(const Name: WideString): WordBool; safecall;
  24.     function DrawTextBiDiModeFlags(Flags: Integer): Integer; safecall;
  25.     function DrawTextBiDiModeFlagsReadingOnly: Integer; safecall;
  26.     function Get_Alignment: TxLeftRight; safecall;
  27.     function Get_BiDiMode: TxBiDiMode; safecall;
  28.     function Get_Caption: WideString; safecall;
  29.     function Get_Checked: WordBool; safecall;
  30.     function Get_Color: OLE_COLOR; safecall;
  31.     function Get_Ctl3D: WordBool; safecall;
  32.     function Get_Cursor: Smallint; safecall;
  33.     function Get_DoubleBuffered: WordBool; safecall;
  34.     function Get_DragCursor: Smallint; safecall;
  35.     function Get_DragMode: TxDragMode; safecall;
  36.     function Get_Enabled: WordBool; safecall;
  37.     function Get_Font: IFontDisp; safecall;
  38.     function Get_ParentColor: WordBool; safecall;
  39.     function Get_ParentCtl3D: WordBool; safecall;
  40.     function Get_ParentFont: WordBool; safecall;
  41.     function Get_Visible: WordBool; safecall;
  42.     function GetControlsAlignment: TxAlignment; safecall;
  43.     function IsRightToLeft: WordBool; safecall;
  44.     function UseRightToLeftAlignment: WordBool; safecall;
  45.     function UseRightToLeftReading: WordBool; safecall;
  46.     function UseRightToLeftScrollBar: WordBool; safecall;
  47.     procedure _Set_Font(const Value: IFontDisp); safecall;
  48.     procedure AboutBox; safecall;
  49.     procedure FlipChildren(AllLevels: WordBool); safecall;
  50.     procedure InitiateAction; safecall;
  51.     procedure Set_Alignment(Value: TxLeftRight); safecall;
  52.     procedure Set_BiDiMode(Value: TxBiDiMode); safecall;
  53.     procedure Set_Caption(const Value: WideString); safecall;
  54.     procedure Set_Checked(Value: WordBool); safecall;
  55.     procedure Set_Color(Value: OLE_COLOR); safecall;
  56.     procedure Set_Ctl3D(Value: WordBool); safecall;
  57.     procedure Set_Cursor(Value: Smallint); safecall;
  58.     procedure Set_DoubleBuffered(Value: WordBool); safecall;
  59.     procedure Set_DragCursor(Value: Smallint); safecall;
  60.     procedure Set_DragMode(Value: TxDragMode); safecall;
  61.     procedure Set_Enabled(Value: WordBool); safecall;
  62.     procedure Set_Font(const Value: IFontDisp); safecall;
  63.     procedure Set_ParentColor(Value: WordBool); safecall;
  64.     procedure Set_ParentCtl3D(Value: WordBool); safecall;
  65.     procedure Set_ParentFont(Value: WordBool); safecall;
  66.     procedure Set_Visible(Value: WordBool); safecall;
  67.   end;
  68.  
  69. implementation
  70.  
  71. uses ComObj, About24;
  72.  
  73. { TRadioButtonX }
  74.  
  75. procedure TRadioButtonX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  76. begin
  77.   { Define property pages here.  Property pages are defined by calling
  78.     DefinePropertyPage with the class id of the page.  For example,
  79.       DefinePropertyPage(Class_RadioButtonXPage); }
  80. end;
  81.  
  82. procedure TRadioButtonX.EventSinkChanged(const EventSink: IUnknown);
  83. begin
  84.   FEvents := EventSink as IRadioButtonXEvents;
  85. end;
  86.  
  87. procedure TRadioButtonX.InitializeControl;
  88. begin
  89.   FDelphiControl := Control as TRadioButton;
  90.   FDelphiControl.OnClick := ClickEvent;
  91.   FDelphiControl.OnDblClick := DblClickEvent;
  92.   FDelphiControl.OnKeyPress := KeyPressEvent;
  93. end;
  94.  
  95. function TRadioButtonX.ClassNameIs(const Name: WideString): WordBool;
  96. begin
  97.   Result := FDelphiControl.ClassNameIs(Name);
  98. end;
  99.  
  100. function TRadioButtonX.DrawTextBiDiModeFlags(Flags: Integer): Integer;
  101. begin
  102.   Result := FDelphiControl.DrawTextBiDiModeFlags(Flags);
  103. end;
  104.  
  105. function TRadioButtonX.DrawTextBiDiModeFlagsReadingOnly: Integer;
  106. begin
  107.   Result := FDelphiControl.DrawTextBiDiModeFlagsReadingOnly;
  108. end;
  109.  
  110. function TRadioButtonX.Get_Alignment: TxLeftRight;
  111. begin
  112.   Result := Ord(FDelphiControl.Alignment);
  113. end;
  114.  
  115. function TRadioButtonX.Get_BiDiMode: TxBiDiMode;
  116. begin
  117.   Result := Ord(FDelphiControl.BiDiMode);
  118. end;
  119.  
  120. function TRadioButtonX.Get_Caption: WideString;
  121. begin
  122.   Result := WideString(FDelphiControl.Caption);
  123. end;
  124.  
  125. function TRadioButtonX.Get_Checked: WordBool;
  126. begin
  127.   Result := FDelphiControl.Checked;
  128. end;
  129.  
  130. function TRadioButtonX.Get_Color: OLE_COLOR;
  131. begin
  132.   Result := OLE_COLOR(FDelphiControl.Color);
  133. end;
  134.  
  135. function TRadioButtonX.Get_Ctl3D: WordBool;
  136. begin
  137.   Result := FDelphiControl.Ctl3D;
  138. end;
  139.  
  140. function TRadioButtonX.Get_Cursor: Smallint;
  141. begin
  142.   Result := Smallint(FDelphiControl.Cursor);
  143. end;
  144.  
  145. function TRadioButtonX.Get_DoubleBuffered: WordBool;
  146. begin
  147.   Result := FDelphiControl.DoubleBuffered;
  148. end;
  149.  
  150. function TRadioButtonX.Get_DragCursor: Smallint;
  151. begin
  152.   Result := Smallint(FDelphiControl.DragCursor);
  153. end;
  154.  
  155. function TRadioButtonX.Get_DragMode: TxDragMode;
  156. begin
  157.   Result := Ord(FDelphiControl.DragMode);
  158. end;
  159.  
  160. function TRadioButtonX.Get_Enabled: WordBool;
  161. begin
  162.   Result := FDelphiControl.Enabled;
  163. end;
  164.  
  165. function TRadioButtonX.Get_Font: IFontDisp;
  166. begin
  167.   GetOleFont(FDelphiControl.Font, Result);
  168. end;
  169.  
  170. function TRadioButtonX.Get_ParentColor: WordBool;
  171. begin
  172.   Result := FDelphiControl.ParentColor;
  173. end;
  174.  
  175. function TRadioButtonX.Get_ParentCtl3D: WordBool;
  176. begin
  177.   Result := FDelphiControl.ParentCtl3D;
  178. end;
  179.  
  180. function TRadioButtonX.Get_ParentFont: WordBool;
  181. begin
  182.   Result := FDelphiControl.ParentFont;
  183. end;
  184.  
  185. function TRadioButtonX.Get_Visible: WordBool;
  186. begin
  187.   Result := FDelphiControl.Visible;
  188. end;
  189.  
  190. function TRadioButtonX.GetControlsAlignment: TxAlignment;
  191. begin
  192.  Result := TxAlignment(FDelphiControl.GetControlsAlignment);
  193. end;
  194.  
  195. function TRadioButtonX.IsRightToLeft: WordBool;
  196. begin
  197.   Result := FDelphiControl.IsRightToLeft;
  198. end;
  199.  
  200. function TRadioButtonX.UseRightToLeftAlignment: WordBool;
  201. begin
  202.   Result := FDelphiControl.UseRightToLeftAlignment;
  203. end;
  204.  
  205. function TRadioButtonX.UseRightToLeftReading: WordBool;
  206. begin
  207.   Result := FDelphiControl.UseRightToLeftReading;
  208. end;
  209.  
  210. function TRadioButtonX.UseRightToLeftScrollBar: WordBool;
  211. begin
  212.   Result := FDelphiControl.UseRightToLeftScrollBar;
  213. end;
  214.  
  215. procedure TRadioButtonX._Set_Font(const Value: IFontDisp);
  216. begin
  217.   SetOleFont(FDelphiControl.Font, Value);
  218. end;
  219.  
  220. procedure TRadioButtonX.AboutBox;
  221. begin
  222.   ShowRadioButtonXAbout;
  223. end;
  224.  
  225. procedure TRadioButtonX.FlipChildren(AllLevels: WordBool);
  226. begin
  227.   FDelphiControl.FlipChildren(AllLevels);
  228. end;
  229.  
  230. procedure TRadioButtonX.InitiateAction;
  231. begin
  232.   FDelphiControl.InitiateAction;
  233. end;
  234.  
  235. procedure TRadioButtonX.Set_Alignment(Value: TxLeftRight);
  236. begin
  237.   FDelphiControl.Alignment := TLeftRight(Value);
  238. end;
  239.  
  240. procedure TRadioButtonX.Set_BiDiMode(Value: TxBiDiMode);
  241. begin
  242.   FDelphiControl.BiDiMode := TBiDiMode(Value);
  243. end;
  244.  
  245. procedure TRadioButtonX.Set_Caption(const Value: WideString);
  246. begin
  247.   FDelphiControl.Caption := TCaption(Value);
  248. end;
  249.  
  250. procedure TRadioButtonX.Set_Checked(Value: WordBool);
  251. begin
  252.   FDelphiControl.Checked := Value;
  253. end;
  254.  
  255. procedure TRadioButtonX.Set_Color(Value: OLE_COLOR);
  256. begin
  257.   FDelphiControl.Color := TColor(Value);
  258. end;
  259.  
  260. procedure TRadioButtonX.Set_Ctl3D(Value: WordBool);
  261. begin
  262.   FDelphiControl.Ctl3D := Value;
  263. end;
  264.  
  265. procedure TRadioButtonX.Set_Cursor(Value: Smallint);
  266. begin
  267.   FDelphiControl.Cursor := TCursor(Value);
  268. end;
  269.  
  270. procedure TRadioButtonX.Set_DoubleBuffered(Value: WordBool);
  271. begin
  272.   FDelphiControl.DoubleBuffered := Value;
  273. end;
  274.  
  275. procedure TRadioButtonX.Set_DragCursor(Value: Smallint);
  276. begin
  277.   FDelphiControl.DragCursor := TCursor(Value);
  278. end;
  279.  
  280. procedure TRadioButtonX.Set_DragMode(Value: TxDragMode);
  281. begin
  282.   FDelphiControl.DragMode := TDragMode(Value);
  283. end;
  284.  
  285. procedure TRadioButtonX.Set_Enabled(Value: WordBool);
  286. begin
  287.   FDelphiControl.Enabled := Value;
  288. end;
  289.  
  290. procedure TRadioButtonX.Set_Font(const Value: IFontDisp);
  291. begin
  292.   SetOleFont(FDelphiControl.Font, Value);
  293. end;
  294.  
  295. procedure TRadioButtonX.Set_ParentColor(Value: WordBool);
  296. begin
  297.   FDelphiControl.ParentColor := Value;
  298. end;
  299.  
  300. procedure TRadioButtonX.Set_ParentCtl3D(Value: WordBool);
  301. begin
  302.   FDelphiControl.ParentCtl3D := Value;
  303. end;
  304.  
  305. procedure TRadioButtonX.Set_ParentFont(Value: WordBool);
  306. begin
  307.   FDelphiControl.ParentFont := Value;
  308. end;
  309.  
  310. procedure TRadioButtonX.Set_Visible(Value: WordBool);
  311. begin
  312.   FDelphiControl.Visible := Value;
  313. end;
  314.  
  315. procedure TRadioButtonX.ClickEvent(Sender: TObject);
  316. begin
  317.   if FEvents <> nil then FEvents.OnClick;
  318. end;
  319.  
  320. procedure TRadioButtonX.DblClickEvent(Sender: TObject);
  321. begin
  322.   if FEvents <> nil then FEvents.OnDblClick;
  323. end;
  324.  
  325. procedure TRadioButtonX.KeyPressEvent(Sender: TObject; var Key: Char);
  326. var
  327.   TempKey: Smallint;
  328. begin
  329.   TempKey := Smallint(Key);
  330.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  331.   Key := Char(TempKey);
  332. end;
  333.  
  334. initialization
  335.   TActiveXControlFactory.Create(
  336.     ComServer,
  337.     TRadioButtonX,
  338.     TRadioButton,
  339.     Class_RadioButtonX,
  340.     24,
  341.     '{695CDB91-02E5-11D2-B20D-00C04FA368D4}',
  342.     0,
  343.     tmApartment);
  344. end.
  345.