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

  1. unit NbokImpl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelC_TLB, ExtCtrls;
  8.  
  9. type
  10.   TNotebookX = class(TActiveXControl, INotebookX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TNotebook;
  14.     FEvents: INotebookXEvents;
  15.     procedure ClickEvent(Sender: TObject);
  16.     procedure DblClickEvent(Sender: TObject);
  17.     procedure PageChangedEvent(Sender: TObject);
  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_ActivePage: WideString; safecall;
  24.     function Get_Color: TColor; safecall;
  25.     function Get_Ctl3D: WordBool; safecall;
  26.     function Get_Cursor: Smallint; safecall;
  27.     function Get_DragCursor: Smallint; safecall;
  28.     function Get_DragMode: TxDragMode; safecall;
  29.     function Get_Enabled: WordBool; safecall;
  30.     function Get_Font: Font; safecall;
  31.     function Get_PageIndex: Integer; safecall;
  32.     function Get_Pages: IStrings; 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_ActivePage(const Value: WideString); safecall;
  38.     procedure Set_Color(Value: TColor); safecall;
  39.     procedure Set_Ctl3D(Value: WordBool); safecall;
  40.     procedure Set_Cursor(Value: Smallint); safecall;
  41.     procedure Set_DragCursor(Value: Smallint); safecall;
  42.     procedure Set_DragMode(Value: TxDragMode); safecall;
  43.     procedure Set_Enabled(Value: WordBool); safecall;
  44.     procedure Set_Font(const Value: Font); safecall;
  45.     procedure Set_PageIndex(Value: Integer); safecall;
  46.     procedure Set_Pages(const Value: IStrings); 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 About17;
  55.  
  56. { TNotebookX }
  57.  
  58. procedure TNotebookX.InitializeControl;
  59. begin
  60.   FDelphiControl := Control as TNotebook;
  61.   FDelphiControl.OnClick := ClickEvent;
  62.   FDelphiControl.OnDblClick := DblClickEvent;
  63.   FDelphiControl.OnPageChanged := PageChangedEvent;
  64. end;
  65.  
  66. procedure TNotebookX.EventSinkChanged(const EventSink: IUnknown);
  67. begin
  68.   FEvents := EventSink as INotebookXEvents;
  69. end;
  70.  
  71. procedure TNotebookX.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_NotebookXPage); }
  76. end;
  77.  
  78. function TNotebookX.Get_ActivePage: WideString;
  79. begin
  80.   Result := WideString(FDelphiControl.ActivePage);
  81. end;
  82.  
  83. function TNotebookX.Get_Color: TColor;
  84. begin
  85.   Result := FDelphiControl.Color;
  86. end;
  87.  
  88. function TNotebookX.Get_Ctl3D: WordBool;
  89. begin
  90.   Result := FDelphiControl.Ctl3D;
  91. end;
  92.  
  93. function TNotebookX.Get_Cursor: Smallint;
  94. begin
  95.   Result := Smallint(FDelphiControl.Cursor);
  96. end;
  97.  
  98. function TNotebookX.Get_DragCursor: Smallint;
  99. begin
  100.   Result := Smallint(FDelphiControl.DragCursor);
  101. end;
  102.  
  103. function TNotebookX.Get_DragMode: TxDragMode;
  104. begin
  105.   Result := Ord(FDelphiControl.DragMode);
  106. end;
  107.  
  108. function TNotebookX.Get_Enabled: WordBool;
  109. begin
  110.   Result := FDelphiControl.Enabled;
  111. end;
  112.  
  113. function TNotebookX.Get_Font: Font;
  114. begin
  115.   GetOleFont(FDelphiControl.Font, Result);
  116. end;
  117.  
  118. function TNotebookX.Get_PageIndex: Integer;
  119. begin
  120.   Result := FDelphiControl.PageIndex;
  121. end;
  122.  
  123. function TNotebookX.Get_Pages: IStrings;
  124. begin
  125.   GetOleStrings(FDelphiControl.Pages, Result);
  126. end;
  127.  
  128. function TNotebookX.Get_ParentColor: WordBool;
  129. begin
  130.   Result := FDelphiControl.ParentColor;
  131. end;
  132.  
  133. function TNotebookX.Get_ParentCtl3D: WordBool;
  134. begin
  135.   Result := FDelphiControl.ParentCtl3D;
  136. end;
  137.  
  138. function TNotebookX.Get_Visible: WordBool;
  139. begin
  140.   Result := FDelphiControl.Visible;
  141. end;
  142.  
  143. procedure TNotebookX.AboutBox;
  144. begin
  145.   ShowNotebookXAbout;
  146. end;
  147.  
  148. procedure TNotebookX.Set_ActivePage(const Value: WideString);
  149. begin
  150.   FDelphiControl.ActivePage := String(Value);
  151. end;
  152.  
  153. procedure TNotebookX.Set_Color(Value: TColor);
  154. begin
  155.   FDelphiControl.Color := Value;
  156. end;
  157.  
  158. procedure TNotebookX.Set_Ctl3D(Value: WordBool);
  159. begin
  160.   FDelphiControl.Ctl3D := Value;
  161. end;
  162.  
  163. procedure TNotebookX.Set_Cursor(Value: Smallint);
  164. begin
  165.   FDelphiControl.Cursor := TCursor(Value);
  166. end;
  167.  
  168. procedure TNotebookX.Set_DragCursor(Value: Smallint);
  169. begin
  170.   FDelphiControl.DragCursor := TCursor(Value);
  171. end;
  172.  
  173. procedure TNotebookX.Set_DragMode(Value: TxDragMode);
  174. begin
  175.   FDelphiControl.DragMode := TDragMode(Value);
  176. end;
  177.  
  178. procedure TNotebookX.Set_Enabled(Value: WordBool);
  179. begin
  180.   FDelphiControl.Enabled := Value;
  181. end;
  182.  
  183. procedure TNotebookX.Set_Font(const Value: Font);
  184. begin
  185.   SetOleFont(FDelphiControl.Font, Value);
  186. end;
  187.  
  188. procedure TNotebookX.Set_PageIndex(Value: Integer);
  189. begin
  190.   FDelphiControl.PageIndex := Value;
  191. end;
  192.  
  193. procedure TNotebookX.Set_Pages(const Value: IStrings);
  194. begin
  195.   SetOleStrings(FDelphiControl.Pages, Value);
  196. end;
  197.  
  198. procedure TNotebookX.Set_ParentColor(Value: WordBool);
  199. begin
  200.   FDelphiControl.ParentColor := Value;
  201. end;
  202.  
  203. procedure TNotebookX.Set_ParentCtl3D(Value: WordBool);
  204. begin
  205.   FDelphiControl.ParentCtl3D := Value;
  206. end;
  207.  
  208. procedure TNotebookX.Set_Visible(Value: WordBool);
  209. begin
  210.   FDelphiControl.Visible := Value;
  211. end;
  212.  
  213. procedure TNotebookX.ClickEvent(Sender: TObject);
  214. begin
  215.   if FEvents <> nil then FEvents.OnClick;
  216. end;
  217.  
  218. procedure TNotebookX.DblClickEvent(Sender: TObject);
  219. begin
  220.   if FEvents <> nil then FEvents.OnDblClick;
  221. end;
  222.  
  223. procedure TNotebookX.PageChangedEvent(Sender: TObject);
  224. begin
  225.   if FEvents <> nil then FEvents.OnPageChanged;
  226. end;
  227.  
  228. initialization
  229.   TActiveXControlFactory.Create(
  230.     ComServer,
  231.     TNotebookX,
  232.     TNotebook,
  233.     Class_NotebookX,
  234.     17,
  235.     '{FA7B8453-9ED7-11D0-AA40-444553540000}',
  236.     0);
  237. end.
  238.