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

  1. unit TabbedNotebookImpl1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelCtrls_TLB, Tabnotbk, ComCtrls;
  8.  
  9. type
  10.   TTabbedNotebookX = class(TActiveXControl, ITabbedNotebookX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TTabbedNotebook;
  14.     FEvents: ITabbedNotebookXEvents;
  15.     procedure ChangeEvent(Sender: TObject; NewTab: Integer;
  16.       var AllowChange: Boolean);
  17.     procedure ClickEvent(Sender: TObject);
  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_ActivePage: WideString; safecall;
  27.     function Get_BiDiMode: TxBiDiMode; safecall;
  28.     function Get_Cursor: Smallint; safecall;
  29.     function Get_DoubleBuffered: WordBool; safecall;
  30.     function Get_Enabled: WordBool; safecall;
  31.     function Get_Font: IFontDisp; safecall;
  32.     function Get_PageIndex: Integer; safecall;
  33.     function Get_Pages: IStrings; safecall;
  34.     function Get_TabFont: IFontDisp; safecall;
  35.     function Get_TabsPerRow: Integer; safecall;
  36.     function Get_TopFont: IFontDisp; safecall;
  37.     function Get_Visible: WordBool; safecall;
  38.     function GetControlsAlignment: TxAlignment; safecall;
  39.     function GetIndexForPage(const PageName: WideString): Integer; safecall;
  40.     function IsRightToLeft: WordBool; safecall;
  41.     function UseRightToLeftAlignment: WordBool; safecall;
  42.     function UseRightToLeftReading: WordBool; safecall;
  43.     function UseRightToLeftScrollBar: WordBool; safecall;
  44.     procedure _Set_Font(const Value: IFontDisp); safecall;
  45.     procedure AboutBox; safecall;
  46.     procedure FlipChildren(AllLevels: WordBool); safecall;
  47.     procedure InitiateAction; safecall;
  48.     procedure Set_ActivePage(const Value: WideString); safecall;
  49.     procedure Set_BiDiMode(Value: TxBiDiMode); safecall;
  50.     procedure Set_Cursor(Value: Smallint); safecall;
  51.     procedure Set_DoubleBuffered(Value: WordBool); safecall;
  52.     procedure Set_Enabled(Value: WordBool); safecall;
  53.     procedure Set_Font(const Value: IFontDisp); safecall;
  54.     procedure Set_PageIndex(Value: Integer); safecall;
  55.     procedure Set_Pages(const Value: IStrings); safecall;
  56.     procedure Set_TabFont(const Value: IFontDisp); safecall;
  57.     procedure Set_TabsPerRow(Value: Integer); safecall;
  58.     procedure Set_Visible(Value: WordBool); safecall;
  59.   end;
  60.  
  61. implementation
  62.  
  63. uses ComObj, About33;
  64.  
  65. { TTabbedNotebookX }
  66.  
  67. procedure TTabbedNotebookX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  68. begin
  69.   { Define property pages here.  Property pages are defined by calling
  70.     DefinePropertyPage with the class id of the page.  For example,
  71.       DefinePropertyPage(Class_TabbedNotebookXPage); }
  72. end;
  73.  
  74. procedure TTabbedNotebookX.EventSinkChanged(const EventSink: IUnknown);
  75. begin
  76.   FEvents := EventSink as ITabbedNotebookXEvents;
  77. end;
  78.  
  79. procedure TTabbedNotebookX.InitializeControl;
  80. begin
  81.   FDelphiControl := Control as TTabbedNotebook;
  82.   FDelphiControl.OnChange := ChangeEvent;
  83.   FDelphiControl.OnClick := ClickEvent;
  84. end;
  85.  
  86. function TTabbedNotebookX.ClassNameIs(const Name: WideString): WordBool;
  87. begin
  88.   Result := FDelphiControl.ClassNameIs(Name);
  89. end;
  90.  
  91. function TTabbedNotebookX.DrawTextBiDiModeFlags(Flags: Integer): Integer;
  92. begin
  93.   Result := FDelphiControl.DrawTextBiDiModeFlags(Flags);
  94. end;
  95.  
  96. function TTabbedNotebookX.DrawTextBiDiModeFlagsReadingOnly: Integer;
  97. begin
  98.   Result := FDelphiControl.DrawTextBiDiModeFlagsReadingOnly;
  99. end;
  100.  
  101. function TTabbedNotebookX.Get_ActivePage: WideString;
  102. begin
  103.   Result := WideString(FDelphiControl.ActivePage);
  104. end;
  105.  
  106. function TTabbedNotebookX.Get_BiDiMode: TxBiDiMode;
  107. begin
  108.   Result := Ord(FDelphiControl.BiDiMode);
  109. end;
  110.  
  111. function TTabbedNotebookX.Get_Cursor: Smallint;
  112. begin
  113.   Result := Smallint(FDelphiControl.Cursor);
  114. end;
  115.  
  116. function TTabbedNotebookX.Get_DoubleBuffered: WordBool;
  117. begin
  118.   Result := FDelphiControl.DoubleBuffered;
  119. end;
  120.  
  121. function TTabbedNotebookX.Get_Enabled: WordBool;
  122. begin
  123.   Result := FDelphiControl.Enabled;
  124. end;
  125.  
  126. function TTabbedNotebookX.Get_Font: IFontDisp;
  127. begin
  128.   GetOleFont(FDelphiControl.Font, Result);
  129. end;
  130.  
  131. function TTabbedNotebookX.Get_PageIndex: Integer;
  132. begin
  133.   Result := FDelphiControl.PageIndex;
  134. end;
  135.  
  136. function TTabbedNotebookX.Get_Pages: IStrings;
  137. begin
  138.   GetOleStrings(FDelphiControl.Pages, Result);
  139. end;
  140.  
  141. function TTabbedNotebookX.Get_TabFont: IFontDisp;
  142. begin
  143.   GetOleFont(FDelphiControl.TabFont, Result);
  144. end;
  145.  
  146. function TTabbedNotebookX.Get_TabsPerRow: Integer;
  147. begin
  148.   Result := FDelphiControl.TabsPerRow;
  149. end;
  150.  
  151. function TTabbedNotebookX.Get_TopFont: IFontDisp;
  152. begin
  153.   GetOleFont(FDelphiControl.TopFont, Result);
  154. end;
  155.  
  156. function TTabbedNotebookX.Get_Visible: WordBool;
  157. begin
  158.   Result := FDelphiControl.Visible;
  159. end;
  160.  
  161. function TTabbedNotebookX.GetControlsAlignment: TxAlignment;
  162. begin
  163.  Result := TxAlignment(FDelphiControl.GetControlsAlignment);
  164. end;
  165.  
  166. function TTabbedNotebookX.GetIndexForPage(
  167.   const PageName: WideString): Integer;
  168. begin
  169.   Result := FDelphiControl.GetIndexForPage(PageName);
  170. end;
  171.  
  172. function TTabbedNotebookX.IsRightToLeft: WordBool;
  173. begin
  174.   Result := FDelphiControl.IsRightToLeft;
  175. end;
  176.  
  177. function TTabbedNotebookX.UseRightToLeftAlignment: WordBool;
  178. begin
  179.   Result := FDelphiControl.UseRightToLeftAlignment;
  180. end;
  181.  
  182. function TTabbedNotebookX.UseRightToLeftReading: WordBool;
  183. begin
  184.   Result := FDelphiControl.UseRightToLeftReading;
  185. end;
  186.  
  187. function TTabbedNotebookX.UseRightToLeftScrollBar: WordBool;
  188. begin
  189.   Result := FDelphiControl.UseRightToLeftScrollBar;
  190. end;
  191.  
  192. procedure TTabbedNotebookX._Set_Font(const Value: IFontDisp);
  193. begin
  194.   SetOleFont(FDelphiControl.Font, Value);
  195. end;
  196.  
  197. procedure TTabbedNotebookX.AboutBox;
  198. begin
  199.   ShowTabbedNotebookXAbout;
  200. end;
  201.  
  202. procedure TTabbedNotebookX.FlipChildren(AllLevels: WordBool);
  203. begin
  204.   FDelphiControl.FlipChildren(AllLevels);
  205. end;
  206.  
  207. procedure TTabbedNotebookX.InitiateAction;
  208. begin
  209.   FDelphiControl.InitiateAction;
  210. end;
  211.  
  212. procedure TTabbedNotebookX.Set_ActivePage(const Value: WideString);
  213. begin
  214.   FDelphiControl.ActivePage := String(Value);
  215. end;
  216.  
  217. procedure TTabbedNotebookX.Set_BiDiMode(Value: TxBiDiMode);
  218. begin
  219.   FDelphiControl.BiDiMode := TBiDiMode(Value);
  220. end;
  221.  
  222. procedure TTabbedNotebookX.Set_Cursor(Value: Smallint);
  223. begin
  224.   FDelphiControl.Cursor := TCursor(Value);
  225. end;
  226.  
  227. procedure TTabbedNotebookX.Set_DoubleBuffered(Value: WordBool);
  228. begin
  229.   FDelphiControl.DoubleBuffered := Value;
  230. end;
  231.  
  232. procedure TTabbedNotebookX.Set_Enabled(Value: WordBool);
  233. begin
  234.   FDelphiControl.Enabled := Value;
  235. end;
  236.  
  237. procedure TTabbedNotebookX.Set_Font(const Value: IFontDisp);
  238. begin
  239.   SetOleFont(FDelphiControl.Font, Value);
  240. end;
  241.  
  242. procedure TTabbedNotebookX.Set_PageIndex(Value: Integer);
  243. begin
  244.   FDelphiControl.PageIndex := Value;
  245. end;
  246.  
  247. procedure TTabbedNotebookX.Set_Pages(const Value: IStrings);
  248. begin
  249.   SetOleStrings(FDelphiControl.Pages, Value);
  250. end;
  251.  
  252. procedure TTabbedNotebookX.Set_TabFont(const Value: IFontDisp);
  253. begin
  254.   SetOleFont(FDelphiControl.TabFont, Value);
  255. end;
  256.  
  257. procedure TTabbedNotebookX.Set_TabsPerRow(Value: Integer);
  258. begin
  259.   FDelphiControl.TabsPerRow := Value;
  260. end;
  261.  
  262. procedure TTabbedNotebookX.Set_Visible(Value: WordBool);
  263. begin
  264.   FDelphiControl.Visible := Value;
  265. end;
  266.  
  267. procedure TTabbedNotebookX.ChangeEvent(Sender: TObject; NewTab: Integer;
  268.   var AllowChange: Boolean);
  269. var
  270.   TempAllowChange: WordBool;
  271. begin
  272.   TempAllowChange := WordBool(AllowChange);
  273.   if FEvents <> nil then FEvents.OnChange(NewTab, TempAllowChange);
  274.   AllowChange := Boolean(TempAllowChange);
  275. end;
  276.  
  277. procedure TTabbedNotebookX.ClickEvent(Sender: TObject);
  278. begin
  279.   if FEvents <> nil then FEvents.OnClick;
  280. end;
  281.  
  282. initialization
  283.   TActiveXControlFactory.Create(
  284.     ComServer,
  285.     TTabbedNotebookX,
  286.     TTabbedNotebook,
  287.     Class_TabbedNotebookX,
  288.     33,
  289.     '{695CDBD3-02E5-11D2-B20D-00C04FA368D4}',
  290.     0,
  291.     tmApartment);
  292. end.
  293.