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

  1. unit PageScrollerImpl1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelCtrls_TLB, ComCtrls;
  8.  
  9. type
  10.   TPageScrollerX = class(TActiveXControl, IPageScrollerX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TPageScroller;
  14.     FEvents: IPageScrollerXEvents;
  15.     procedure ClickEvent(Sender: TObject);
  16.     procedure DblClickEvent(Sender: TObject);
  17.     procedure KeyPressEvent(Sender: TObject; var Key: Char);
  18.     procedure ResizeEvent(Sender: TObject);
  19.   protected
  20.     { Protected declarations }
  21.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  22.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  23.     procedure InitializeControl; override;
  24.     function ClassNameIs(const Name: WideString): WordBool; safecall;
  25.     function DrawTextBiDiModeFlags(Flags: Integer): Integer; safecall;
  26.     function DrawTextBiDiModeFlagsReadingOnly: Integer; safecall;
  27.     function Get_AutoScroll: WordBool; safecall;
  28.     function Get_BiDiMode: TxBiDiMode; safecall;
  29.     function Get_ButtonSize: Integer; safecall;
  30.     function Get_Color: OLE_COLOR; safecall;
  31.     function Get_Cursor: Smallint; safecall;
  32.     function Get_DockSite: WordBool; safecall;
  33.     function Get_DoubleBuffered: WordBool; safecall;
  34.     function Get_DragCursor: Smallint; safecall;
  35.     function Get_DragMode: TxDragMode; safecall;
  36.     function Get_DragScroll: WordBool; safecall;
  37.     function Get_Enabled: WordBool; safecall;
  38.     function Get_Font: IFontDisp; safecall;
  39.     function Get_Margin: Integer; safecall;
  40.     function Get_Orientation: TxPageScrollerOrientation; safecall;
  41.     function Get_ParentColor: WordBool; safecall;
  42.     function Get_ParentFont: WordBool; safecall;
  43.     function Get_Position: Integer; safecall;
  44.     function Get_Visible: WordBool; safecall;
  45.     function GetButtonState(
  46.       Button: TxPageScrollerButton): TxPageScrollerButtonState; safecall;
  47.     function GetControlsAlignment: TxAlignment; safecall;
  48.     function IsRightToLeft: WordBool; safecall;
  49.     function UseRightToLeftAlignment: WordBool; safecall;
  50.     function UseRightToLeftReading: WordBool; safecall;
  51.     function UseRightToLeftScrollBar: WordBool; safecall;
  52.     procedure _Set_Font(const Value: IFontDisp); safecall;
  53.     procedure AboutBox; safecall;
  54.     procedure FlipChildren(AllLevels: WordBool); safecall;
  55.     procedure InitiateAction; safecall;
  56.     procedure Set_AutoScroll(Value: WordBool); safecall;
  57.     procedure Set_BiDiMode(Value: TxBiDiMode); safecall;
  58.     procedure Set_ButtonSize(Value: Integer); safecall;
  59.     procedure Set_Color(Value: OLE_COLOR); safecall;
  60.     procedure Set_Cursor(Value: Smallint); safecall;
  61.     procedure Set_DockSite(Value: WordBool); safecall;
  62.     procedure Set_DoubleBuffered(Value: WordBool); safecall;
  63.     procedure Set_DragCursor(Value: Smallint); safecall;
  64.     procedure Set_DragMode(Value: TxDragMode); safecall;
  65.     procedure Set_DragScroll(Value: WordBool); safecall;
  66.     procedure Set_Enabled(Value: WordBool); safecall;
  67.     procedure Set_Font(const Value: IFontDisp); safecall;
  68.     procedure Set_Margin(Value: Integer); safecall;
  69.     procedure Set_Orientation(Value: TxPageScrollerOrientation); safecall;
  70.     procedure Set_ParentColor(Value: WordBool); safecall;
  71.     procedure Set_ParentFont(Value: WordBool); safecall;
  72.     procedure Set_Position(Value: Integer); safecall;
  73.     procedure Set_Visible(Value: WordBool); safecall;
  74.   end;
  75.  
  76. implementation
  77.  
  78. uses ComObj, About21;
  79.  
  80. { TPageScrollerX }
  81.  
  82. procedure TPageScrollerX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  83. begin
  84.   { Define property pages here.  Property pages are defined by calling
  85.     DefinePropertyPage with the class id of the page.  For example,
  86.       DefinePropertyPage(Class_PageScrollerXPage); }
  87. end;
  88.  
  89. procedure TPageScrollerX.EventSinkChanged(const EventSink: IUnknown);
  90. begin
  91.   FEvents := EventSink as IPageScrollerXEvents;
  92. end;
  93.  
  94. procedure TPageScrollerX.InitializeControl;
  95. begin
  96.   FDelphiControl := Control as TPageScroller;
  97.   FDelphiControl.OnClick := ClickEvent;
  98.   FDelphiControl.OnDblClick := DblClickEvent;
  99.   FDelphiControl.OnKeyPress := KeyPressEvent;
  100.   FDelphiControl.OnResize := ResizeEvent;
  101. end;
  102.  
  103. function TPageScrollerX.ClassNameIs(const Name: WideString): WordBool;
  104. begin
  105.   Result := FDelphiControl.ClassNameIs(Name);
  106. end;
  107.  
  108. function TPageScrollerX.DrawTextBiDiModeFlags(Flags: Integer): Integer;
  109. begin
  110.   Result := FDelphiControl.DrawTextBiDiModeFlags(Flags);
  111. end;
  112.  
  113. function TPageScrollerX.DrawTextBiDiModeFlagsReadingOnly: Integer;
  114. begin
  115.   Result := FDelphiControl.DrawTextBiDiModeFlagsReadingOnly;
  116. end;
  117.  
  118. function TPageScrollerX.Get_AutoScroll: WordBool;
  119. begin
  120.   Result := FDelphiControl.AutoScroll;
  121. end;
  122.  
  123. function TPageScrollerX.Get_BiDiMode: TxBiDiMode;
  124. begin
  125.   Result := Ord(FDelphiControl.BiDiMode);
  126. end;
  127.  
  128. function TPageScrollerX.Get_ButtonSize: Integer;
  129. begin
  130.   Result := FDelphiControl.ButtonSize;
  131. end;
  132.  
  133. function TPageScrollerX.Get_Color: OLE_COLOR;
  134. begin
  135.   Result := OLE_COLOR(FDelphiControl.Color);
  136. end;
  137.  
  138. function TPageScrollerX.Get_Cursor: Smallint;
  139. begin
  140.   Result := Smallint(FDelphiControl.Cursor);
  141. end;
  142.  
  143. function TPageScrollerX.Get_DockSite: WordBool;
  144. begin
  145.   Result := FDelphiControl.DockSite;
  146. end;
  147.  
  148. function TPageScrollerX.Get_DoubleBuffered: WordBool;
  149. begin
  150.   Result := FDelphiControl.DoubleBuffered;
  151. end;
  152.  
  153. function TPageScrollerX.Get_DragCursor: Smallint;
  154. begin
  155.   Result := Smallint(FDelphiControl.DragCursor);
  156. end;
  157.  
  158. function TPageScrollerX.Get_DragMode: TxDragMode;
  159. begin
  160.   Result := Ord(FDelphiControl.DragMode);
  161. end;
  162.  
  163. function TPageScrollerX.Get_DragScroll: WordBool;
  164. begin
  165.   Result := FDelphiControl.DragScroll;
  166. end;
  167.  
  168. function TPageScrollerX.Get_Enabled: WordBool;
  169. begin
  170.   Result := FDelphiControl.Enabled;
  171. end;
  172.  
  173. function TPageScrollerX.Get_Font: IFontDisp;
  174. begin
  175.   GetOleFont(FDelphiControl.Font, Result);
  176. end;
  177.  
  178. function TPageScrollerX.Get_Margin: Integer;
  179. begin
  180.   Result := FDelphiControl.Margin;
  181. end;
  182.  
  183. function TPageScrollerX.Get_Orientation: TxPageScrollerOrientation;
  184. begin
  185.   Result := Ord(FDelphiControl.Orientation);
  186. end;
  187.  
  188. function TPageScrollerX.Get_ParentColor: WordBool;
  189. begin
  190.   Result := FDelphiControl.ParentColor;
  191. end;
  192.  
  193. function TPageScrollerX.Get_ParentFont: WordBool;
  194. begin
  195.   Result := FDelphiControl.ParentFont;
  196. end;
  197.  
  198. function TPageScrollerX.Get_Position: Integer;
  199. begin
  200.   Result := FDelphiControl.Position;
  201. end;
  202.  
  203. function TPageScrollerX.Get_Visible: WordBool;
  204. begin
  205.   Result := FDelphiControl.Visible;
  206. end;
  207.  
  208. function TPageScrollerX.GetButtonState(
  209.   Button: TxPageScrollerButton): TxPageScrollerButtonState;
  210. begin
  211.  Result := TxPageScrollerButtonState(FDelphiControl.GetButtonState(TPageScrollerButton(Button)));
  212. end;
  213.  
  214. function TPageScrollerX.GetControlsAlignment: TxAlignment;
  215. begin
  216.  Result := TxAlignment(FDelphiControl.GetControlsAlignment);
  217. end;
  218.  
  219. function TPageScrollerX.IsRightToLeft: WordBool;
  220. begin
  221.   Result := FDelphiControl.IsRightToLeft;
  222. end;
  223.  
  224. function TPageScrollerX.UseRightToLeftAlignment: WordBool;
  225. begin
  226.   Result := FDelphiControl.UseRightToLeftAlignment;
  227. end;
  228.  
  229. function TPageScrollerX.UseRightToLeftReading: WordBool;
  230. begin
  231.   Result := FDelphiControl.UseRightToLeftReading;
  232. end;
  233.  
  234. function TPageScrollerX.UseRightToLeftScrollBar: WordBool;
  235. begin
  236.   Result := FDelphiControl.UseRightToLeftScrollBar;
  237. end;
  238.  
  239. procedure TPageScrollerX._Set_Font(const Value: IFontDisp);
  240. begin
  241.   SetOleFont(FDelphiControl.Font, Value);
  242. end;
  243.  
  244. procedure TPageScrollerX.AboutBox;
  245. begin
  246.   ShowPageScrollerXAbout;
  247. end;
  248.  
  249. procedure TPageScrollerX.FlipChildren(AllLevels: WordBool);
  250. begin
  251.   FDelphiControl.FlipChildren(AllLevels);
  252. end;
  253.  
  254. procedure TPageScrollerX.InitiateAction;
  255. begin
  256.   FDelphiControl.InitiateAction;
  257. end;
  258.  
  259. procedure TPageScrollerX.Set_AutoScroll(Value: WordBool);
  260. begin
  261.   FDelphiControl.AutoScroll := Value;
  262. end;
  263.  
  264. procedure TPageScrollerX.Set_BiDiMode(Value: TxBiDiMode);
  265. begin
  266.   FDelphiControl.BiDiMode := TBiDiMode(Value);
  267. end;
  268.  
  269. procedure TPageScrollerX.Set_ButtonSize(Value: Integer);
  270. begin
  271.   FDelphiControl.ButtonSize := Value;
  272. end;
  273.  
  274. procedure TPageScrollerX.Set_Color(Value: OLE_COLOR);
  275. begin
  276.   FDelphiControl.Color := TColor(Value);
  277. end;
  278.  
  279. procedure TPageScrollerX.Set_Cursor(Value: Smallint);
  280. begin
  281.   FDelphiControl.Cursor := TCursor(Value);
  282. end;
  283.  
  284. procedure TPageScrollerX.Set_DockSite(Value: WordBool);
  285. begin
  286.   FDelphiControl.DockSite := Value;
  287. end;
  288.  
  289. procedure TPageScrollerX.Set_DoubleBuffered(Value: WordBool);
  290. begin
  291.   FDelphiControl.DoubleBuffered := Value;
  292. end;
  293.  
  294. procedure TPageScrollerX.Set_DragCursor(Value: Smallint);
  295. begin
  296.   FDelphiControl.DragCursor := TCursor(Value);
  297. end;
  298.  
  299. procedure TPageScrollerX.Set_DragMode(Value: TxDragMode);
  300. begin
  301.   FDelphiControl.DragMode := TDragMode(Value);
  302. end;
  303.  
  304. procedure TPageScrollerX.Set_DragScroll(Value: WordBool);
  305. begin
  306.   FDelphiControl.DragScroll := Value;
  307. end;
  308.  
  309. procedure TPageScrollerX.Set_Enabled(Value: WordBool);
  310. begin
  311.   FDelphiControl.Enabled := Value;
  312. end;
  313.  
  314. procedure TPageScrollerX.Set_Font(const Value: IFontDisp);
  315. begin
  316.   SetOleFont(FDelphiControl.Font, Value);
  317. end;
  318.  
  319. procedure TPageScrollerX.Set_Margin(Value: Integer);
  320. begin
  321.   FDelphiControl.Margin := Value;
  322. end;
  323.  
  324. procedure TPageScrollerX.Set_Orientation(Value: TxPageScrollerOrientation);
  325. begin
  326.   FDelphiControl.Orientation := TPageScrollerOrientation(Value);
  327. end;
  328.  
  329. procedure TPageScrollerX.Set_ParentColor(Value: WordBool);
  330. begin
  331.   FDelphiControl.ParentColor := Value;
  332. end;
  333.  
  334. procedure TPageScrollerX.Set_ParentFont(Value: WordBool);
  335. begin
  336.   FDelphiControl.ParentFont := Value;
  337. end;
  338.  
  339. procedure TPageScrollerX.Set_Position(Value: Integer);
  340. begin
  341.   FDelphiControl.Position := Value;
  342. end;
  343.  
  344. procedure TPageScrollerX.Set_Visible(Value: WordBool);
  345. begin
  346.   FDelphiControl.Visible := Value;
  347. end;
  348.  
  349. procedure TPageScrollerX.ClickEvent(Sender: TObject);
  350. begin
  351.   if FEvents <> nil then FEvents.OnClick;
  352. end;
  353.  
  354. procedure TPageScrollerX.DblClickEvent(Sender: TObject);
  355. begin
  356.   if FEvents <> nil then FEvents.OnDblClick;
  357. end;
  358.  
  359. procedure TPageScrollerX.KeyPressEvent(Sender: TObject; var Key: Char);
  360. var
  361.   TempKey: Smallint;
  362. begin
  363.   TempKey := Smallint(Key);
  364.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  365.   Key := Char(TempKey);
  366. end;
  367.  
  368. procedure TPageScrollerX.ResizeEvent(Sender: TObject);
  369. begin
  370.   if FEvents <> nil then FEvents.OnResize;
  371. end;
  372.  
  373. initialization
  374.   TActiveXControlFactory.Create(
  375.     ComServer,
  376.     TPageScrollerX,
  377.     TPageScroller,
  378.     Class_PageScrollerX,
  379.     21,
  380.     '{695CDB7B-02E5-11D2-B20D-00C04FA368D4}',
  381.     OLEMISC_SIMPLEFRAME or OLEMISC_ACTSLIKELABEL,
  382.     tmApartment);
  383. end.
  384.