home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161b.iso / full / delphi / RUNIMAGE / DELPHI30 / DEMOS / ACTIVEX / DELCTRLS / STXTIMPL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-08-04  |  6.0 KB  |  231 lines

  1. unit STxtImpl;
  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.   TStaticTextX = class(TActiveXControl, IStaticTextX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TStaticText;
  14.     FEvents: IStaticTextXEvents;
  15.     procedure ClickEvent(Sender: TObject);
  16.     procedure DblClickEvent(Sender: TObject);
  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: TxAlignment; safecall;
  23.     function Get_AutoSize: WordBool; safecall;
  24.     function Get_BorderStyle: TxStaticBorderStyle; safecall;
  25.     function Get_Caption: WideString; safecall;
  26.     function Get_Color: TColor; safecall;
  27.     function Get_Cursor: Smallint; safecall;
  28.     function Get_DragCursor: Smallint; safecall;
  29.     function Get_DragMode: TxDragMode; safecall;
  30.     function Get_Enabled: WordBool; safecall;
  31.     function Get_Font: Font; safecall;
  32.     function Get_ParentColor: WordBool; safecall;
  33.     function Get_ShowAccelChar: WordBool; safecall;
  34.     function Get_Visible: WordBool; safecall;
  35.     procedure AboutBox; safecall;
  36.     procedure Set_Alignment(Value: TxAlignment); safecall;
  37.     procedure Set_AutoSize(Value: WordBool); safecall;
  38.     procedure Set_BorderStyle(Value: TxStaticBorderStyle); safecall;
  39.     procedure Set_Caption(const Value: WideString); safecall;
  40.     procedure Set_Color(Value: TColor); safecall;
  41.     procedure Set_Cursor(Value: Smallint); safecall;
  42.     procedure Set_DragCursor(Value: Smallint); safecall;
  43.     procedure Set_DragMode(Value: TxDragMode); safecall;
  44.     procedure Set_Enabled(Value: WordBool); safecall;
  45.     procedure Set_Font(const Value: Font); safecall;
  46.     procedure Set_ParentColor(Value: WordBool); safecall;
  47.     procedure Set_ShowAccelChar(Value: WordBool); safecall;
  48.     procedure Set_Visible(Value: WordBool); safecall;
  49.   end;
  50.  
  51. implementation
  52.  
  53. uses About28;
  54.  
  55. { TStaticTextX }
  56.  
  57. procedure TStaticTextX.InitializeControl;
  58. begin
  59.   FDelphiControl := Control as TStaticText;
  60.   FDelphiControl.OnClick := ClickEvent;
  61.   FDelphiControl.OnDblClick := DblClickEvent;
  62. end;
  63.  
  64. procedure TStaticTextX.EventSinkChanged(const EventSink: IUnknown);
  65. begin
  66.   FEvents := EventSink as IStaticTextXEvents;
  67. end;
  68.  
  69. procedure TStaticTextX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  70. begin
  71.   { Define property pages here.  Property pages are defined by calling
  72.     DefinePropertyPage with the class id of the page.  For example,
  73.       DefinePropertyPage(Class_StaticTextXPage); }
  74. end;
  75.  
  76. function TStaticTextX.Get_Alignment: TxAlignment;
  77. begin
  78.   Result := Ord(FDelphiControl.Alignment);
  79. end;
  80.  
  81. function TStaticTextX.Get_AutoSize: WordBool;
  82. begin
  83.   Result := FDelphiControl.AutoSize;
  84. end;
  85.  
  86. function TStaticTextX.Get_BorderStyle: TxStaticBorderStyle;
  87. begin
  88.   Result := Ord(FDelphiControl.BorderStyle);
  89. end;
  90.  
  91. function TStaticTextX.Get_Caption: WideString;
  92. begin
  93.   Result := WideString(FDelphiControl.Caption);
  94. end;
  95.  
  96. function TStaticTextX.Get_Color: TColor;
  97. begin
  98.   Result := FDelphiControl.Color;
  99. end;
  100.  
  101. function TStaticTextX.Get_Cursor: Smallint;
  102. begin
  103.   Result := Smallint(FDelphiControl.Cursor);
  104. end;
  105.  
  106. function TStaticTextX.Get_DragCursor: Smallint;
  107. begin
  108.   Result := Smallint(FDelphiControl.DragCursor);
  109. end;
  110.  
  111. function TStaticTextX.Get_DragMode: TxDragMode;
  112. begin
  113.   Result := Ord(FDelphiControl.DragMode);
  114. end;
  115.  
  116. function TStaticTextX.Get_Enabled: WordBool;
  117. begin
  118.   Result := FDelphiControl.Enabled;
  119. end;
  120.  
  121. function TStaticTextX.Get_Font: Font;
  122. begin
  123.   GetOleFont(FDelphiControl.Font, Result);
  124. end;
  125.  
  126. function TStaticTextX.Get_ParentColor: WordBool;
  127. begin
  128.   Result := FDelphiControl.ParentColor;
  129. end;
  130.  
  131. function TStaticTextX.Get_ShowAccelChar: WordBool;
  132. begin
  133.   Result := FDelphiControl.ShowAccelChar;
  134. end;
  135.  
  136. function TStaticTextX.Get_Visible: WordBool;
  137. begin
  138.   Result := FDelphiControl.Visible;
  139. end;
  140.  
  141. procedure TStaticTextX.AboutBox;
  142. begin
  143.   ShowStaticTextXAbout;
  144. end;
  145.  
  146. procedure TStaticTextX.Set_Alignment(Value: TxAlignment);
  147. begin
  148.   FDelphiControl.Alignment := TAlignment(Value);
  149. end;
  150.  
  151. procedure TStaticTextX.Set_AutoSize(Value: WordBool);
  152. begin
  153.   FDelphiControl.AutoSize := Value;
  154. end;
  155.  
  156. procedure TStaticTextX.Set_BorderStyle(Value: TxStaticBorderStyle);
  157. begin
  158.   FDelphiControl.BorderStyle := TStaticBorderStyle(Value);
  159. end;
  160.  
  161. procedure TStaticTextX.Set_Caption(const Value: WideString);
  162. begin
  163.   FDelphiControl.Caption := TCaption(Value);
  164. end;
  165.  
  166. procedure TStaticTextX.Set_Color(Value: TColor);
  167. begin
  168.   FDelphiControl.Color := Value;
  169. end;
  170.  
  171. procedure TStaticTextX.Set_Cursor(Value: Smallint);
  172. begin
  173.   FDelphiControl.Cursor := TCursor(Value);
  174. end;
  175.  
  176. procedure TStaticTextX.Set_DragCursor(Value: Smallint);
  177. begin
  178.   FDelphiControl.DragCursor := TCursor(Value);
  179. end;
  180.  
  181. procedure TStaticTextX.Set_DragMode(Value: TxDragMode);
  182. begin
  183.   FDelphiControl.DragMode := TDragMode(Value);
  184. end;
  185.  
  186. procedure TStaticTextX.Set_Enabled(Value: WordBool);
  187. begin
  188.   FDelphiControl.Enabled := Value;
  189. end;
  190.  
  191. procedure TStaticTextX.Set_Font(const Value: Font);
  192. begin
  193.   SetOleFont(FDelphiControl.Font, Value);
  194. end;
  195.  
  196. procedure TStaticTextX.Set_ParentColor(Value: WordBool);
  197. begin
  198.   FDelphiControl.ParentColor := Value;
  199. end;
  200.  
  201. procedure TStaticTextX.Set_ShowAccelChar(Value: WordBool);
  202. begin
  203.   FDelphiControl.ShowAccelChar := Value;
  204. end;
  205.  
  206. procedure TStaticTextX.Set_Visible(Value: WordBool);
  207. begin
  208.   FDelphiControl.Visible := Value;
  209. end;
  210.  
  211. procedure TStaticTextX.ClickEvent(Sender: TObject);
  212. begin
  213.   if FEvents <> nil then FEvents.OnClick;
  214. end;
  215.  
  216. procedure TStaticTextX.DblClickEvent(Sender: TObject);
  217. begin
  218.   if FEvents <> nil then FEvents.OnDblClick;
  219. end;
  220.  
  221. initialization
  222.   TActiveXControlFactory.Create(
  223.     ComServer,
  224.     TStaticTextX,
  225.     TStaticText,
  226.     Class_StaticTextX,
  227.     28,
  228.     '{FA7B8674-9ED7-11D0-AA40-444553540000}',
  229.     0);
  230. end.
  231.