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

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