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

  1. unit TabSetImpl1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelCtrls_TLB, Tabs;
  8.  
  9. type
  10.   TTabSetX = class(TActiveXControl, ITabSetX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TTabSet;
  14.     FEvents: ITabSetXEvents;
  15.     procedure ChangeEvent(Sender: TObject; NewTab: Integer;
  16.       var AllowChange: Boolean);
  17.     procedure ClickEvent(Sender: TObject);
  18.     procedure MeasureTabEvent(Sender: TObject; Index: Integer;
  19.       var TabWidth: Integer);
  20.   protected
  21.     { Protected declarations }
  22.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  23.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  24.     procedure InitializeControl; override;
  25.     function ClassNameIs(const Name: WideString): WordBool; safecall;
  26.     function DrawTextBiDiModeFlags(Flags: Integer): Integer; safecall;
  27.     function DrawTextBiDiModeFlagsReadingOnly: Integer; safecall;
  28.     function Get_AutoScroll: WordBool; safecall;
  29.     function Get_BackgroundColor: OLE_COLOR; safecall;
  30.     function Get_BiDiMode: TxBiDiMode; safecall;
  31.     function Get_Cursor: Smallint; safecall;
  32.     function Get_DitherBackground: WordBool; safecall;
  33.     function Get_DoubleBuffered: WordBool; safecall;
  34.     function Get_DragCursor: Smallint; safecall;
  35.     function Get_DragMode: TxDragMode; safecall;
  36.     function Get_Enabled: WordBool; safecall;
  37.     function Get_EndMargin: Integer; safecall;
  38.     function Get_FirstIndex: Integer; safecall;
  39.     function Get_Font: IFontDisp; safecall;
  40.     function Get_SelectedColor: OLE_COLOR; safecall;
  41.     function Get_StartMargin: Integer; safecall;
  42.     function Get_Style: TxTabStyle; safecall;
  43.     function Get_TabHeight: Integer; safecall;
  44.     function Get_TabIndex: Integer; safecall;
  45.     function Get_Tabs: IStrings; safecall;
  46.     function Get_UnselectedColor: OLE_COLOR; safecall;
  47.     function Get_Visible: WordBool; safecall;
  48.     function Get_VisibleTabs: Integer; safecall;
  49.     function GetControlsAlignment: TxAlignment; safecall;
  50.     function IsRightToLeft: WordBool; safecall;
  51.     function UseRightToLeftAlignment: WordBool; safecall;
  52.     function UseRightToLeftReading: WordBool; safecall;
  53.     function UseRightToLeftScrollBar: WordBool; safecall;
  54.     procedure _Set_Font(const Value: IFontDisp); safecall;
  55.     procedure AboutBox; safecall;
  56.     procedure FlipChildren(AllLevels: WordBool); safecall;
  57.     procedure InitiateAction; safecall;
  58.     procedure SelectNext(Direction: WordBool); safecall;
  59.     procedure Set_AutoScroll(Value: WordBool); safecall;
  60.     procedure Set_BackgroundColor(Value: OLE_COLOR); safecall;
  61.     procedure Set_BiDiMode(Value: TxBiDiMode); safecall;
  62.     procedure Set_Cursor(Value: Smallint); safecall;
  63.     procedure Set_DitherBackground(Value: WordBool); safecall;
  64.     procedure Set_DoubleBuffered(Value: WordBool); safecall;
  65.     procedure Set_DragCursor(Value: Smallint); safecall;
  66.     procedure Set_DragMode(Value: TxDragMode); safecall;
  67.     procedure Set_Enabled(Value: WordBool); safecall;
  68.     procedure Set_EndMargin(Value: Integer); safecall;
  69.     procedure Set_FirstIndex(Value: Integer); safecall;
  70.     procedure Set_Font(const Value: IFontDisp); safecall;
  71.     procedure Set_SelectedColor(Value: OLE_COLOR); safecall;
  72.     procedure Set_StartMargin(Value: Integer); safecall;
  73.     procedure Set_Style(Value: TxTabStyle); safecall;
  74.     procedure Set_TabHeight(Value: Integer); safecall;
  75.     procedure Set_TabIndex(Value: Integer); safecall;
  76.     procedure Set_Tabs(const Value: IStrings); safecall;
  77.     procedure Set_UnselectedColor(Value: OLE_COLOR); safecall;
  78.     procedure Set_Visible(Value: WordBool); safecall;
  79.   end;
  80.  
  81. implementation
  82.  
  83. uses ComObj, About35;
  84.  
  85. { TTabSetX }
  86.  
  87. procedure TTabSetX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  88. begin
  89.   { Define property pages here.  Property pages are defined by calling
  90.     DefinePropertyPage with the class id of the page.  For example,
  91.       DefinePropertyPage(Class_TabSetXPage); }
  92. end;
  93.  
  94. procedure TTabSetX.EventSinkChanged(const EventSink: IUnknown);
  95. begin
  96.   FEvents := EventSink as ITabSetXEvents;
  97. end;
  98.  
  99. procedure TTabSetX.InitializeControl;
  100. begin
  101.   FDelphiControl := Control as TTabSet;
  102.   FDelphiControl.OnChange := ChangeEvent;
  103.   FDelphiControl.OnClick := ClickEvent;
  104.   FDelphiControl.OnMeasureTab := MeasureTabEvent;
  105. end;
  106.  
  107. function TTabSetX.ClassNameIs(const Name: WideString): WordBool;
  108. begin
  109.   Result := FDelphiControl.ClassNameIs(Name);
  110. end;
  111.  
  112. function TTabSetX.DrawTextBiDiModeFlags(Flags: Integer): Integer;
  113. begin
  114.   Result := FDelphiControl.DrawTextBiDiModeFlags(Flags);
  115. end;
  116.  
  117. function TTabSetX.DrawTextBiDiModeFlagsReadingOnly: Integer;
  118. begin
  119.   Result := FDelphiControl.DrawTextBiDiModeFlagsReadingOnly;
  120. end;
  121.  
  122. function TTabSetX.Get_AutoScroll: WordBool;
  123. begin
  124.   Result := FDelphiControl.AutoScroll;
  125. end;
  126.  
  127. function TTabSetX.Get_BackgroundColor: OLE_COLOR;
  128. begin
  129.   Result := OLE_COLOR(FDelphiControl.BackgroundColor);
  130. end;
  131.  
  132. function TTabSetX.Get_BiDiMode: TxBiDiMode;
  133. begin
  134.   Result := Ord(FDelphiControl.BiDiMode);
  135. end;
  136.  
  137. function TTabSetX.Get_Cursor: Smallint;
  138. begin
  139.   Result := Smallint(FDelphiControl.Cursor);
  140. end;
  141.  
  142. function TTabSetX.Get_DitherBackground: WordBool;
  143. begin
  144.   Result := FDelphiControl.DitherBackground;
  145. end;
  146.  
  147. function TTabSetX.Get_DoubleBuffered: WordBool;
  148. begin
  149.   Result := FDelphiControl.DoubleBuffered;
  150. end;
  151.  
  152. function TTabSetX.Get_DragCursor: Smallint;
  153. begin
  154.   Result := Smallint(FDelphiControl.DragCursor);
  155. end;
  156.  
  157. function TTabSetX.Get_DragMode: TxDragMode;
  158. begin
  159.   Result := Ord(FDelphiControl.DragMode);
  160. end;
  161.  
  162. function TTabSetX.Get_Enabled: WordBool;
  163. begin
  164.   Result := FDelphiControl.Enabled;
  165. end;
  166.  
  167. function TTabSetX.Get_EndMargin: Integer;
  168. begin
  169.   Result := FDelphiControl.EndMargin;
  170. end;
  171.  
  172. function TTabSetX.Get_FirstIndex: Integer;
  173. begin
  174.   Result := FDelphiControl.FirstIndex;
  175. end;
  176.  
  177. function TTabSetX.Get_Font: IFontDisp;
  178. begin
  179.   GetOleFont(FDelphiControl.Font, Result);
  180. end;
  181.  
  182. function TTabSetX.Get_SelectedColor: OLE_COLOR;
  183. begin
  184.   Result := OLE_COLOR(FDelphiControl.SelectedColor);
  185. end;
  186.  
  187. function TTabSetX.Get_StartMargin: Integer;
  188. begin
  189.   Result := FDelphiControl.StartMargin;
  190. end;
  191.  
  192. function TTabSetX.Get_Style: TxTabStyle;
  193. begin
  194.   Result := Ord(FDelphiControl.Style);
  195. end;
  196.  
  197. function TTabSetX.Get_TabHeight: Integer;
  198. begin
  199.   Result := FDelphiControl.TabHeight;
  200. end;
  201.  
  202. function TTabSetX.Get_TabIndex: Integer;
  203. begin
  204.   Result := FDelphiControl.TabIndex;
  205. end;
  206.  
  207. function TTabSetX.Get_Tabs: IStrings;
  208. begin
  209.   GetOleStrings(FDelphiControl.Tabs, Result);
  210. end;
  211.  
  212. function TTabSetX.Get_UnselectedColor: OLE_COLOR;
  213. begin
  214.   Result := OLE_COLOR(FDelphiControl.UnselectedColor);
  215. end;
  216.  
  217. function TTabSetX.Get_Visible: WordBool;
  218. begin
  219.   Result := FDelphiControl.Visible;
  220. end;
  221.  
  222. function TTabSetX.Get_VisibleTabs: Integer;
  223. begin
  224.   Result := FDelphiControl.VisibleTabs;
  225. end;
  226.  
  227. function TTabSetX.GetControlsAlignment: TxAlignment;
  228. begin
  229.  Result := TxAlignment(FDelphiControl.GetControlsAlignment);
  230. end;
  231.  
  232. function TTabSetX.IsRightToLeft: WordBool;
  233. begin
  234.   Result := FDelphiControl.IsRightToLeft;
  235. end;
  236.  
  237. function TTabSetX.UseRightToLeftAlignment: WordBool;
  238. begin
  239.   Result := FDelphiControl.UseRightToLeftAlignment;
  240. end;
  241.  
  242. function TTabSetX.UseRightToLeftReading: WordBool;
  243. begin
  244.   Result := FDelphiControl.UseRightToLeftReading;
  245. end;
  246.  
  247. function TTabSetX.UseRightToLeftScrollBar: WordBool;
  248. begin
  249.   Result := FDelphiControl.UseRightToLeftScrollBar;
  250. end;
  251.  
  252. procedure TTabSetX._Set_Font(const Value: IFontDisp);
  253. begin
  254.   SetOleFont(FDelphiControl.Font, Value);
  255. end;
  256.  
  257. procedure TTabSetX.AboutBox;
  258. begin
  259.   ShowTabSetXAbout;
  260. end;
  261.  
  262. procedure TTabSetX.FlipChildren(AllLevels: WordBool);
  263. begin
  264.   FDelphiControl.FlipChildren(AllLevels);
  265. end;
  266.  
  267. procedure TTabSetX.InitiateAction;
  268. begin
  269.   FDelphiControl.InitiateAction;
  270. end;
  271.  
  272. procedure TTabSetX.SelectNext(Direction: WordBool);
  273. begin
  274.   FDelphiControl.SelectNext(Direction);
  275. end;
  276.  
  277. procedure TTabSetX.Set_AutoScroll(Value: WordBool);
  278. begin
  279.   FDelphiControl.AutoScroll := Value;
  280. end;
  281.  
  282. procedure TTabSetX.Set_BackgroundColor(Value: OLE_COLOR);
  283. begin
  284.   FDelphiControl.BackgroundColor := TColor(Value);
  285. end;
  286.  
  287. procedure TTabSetX.Set_BiDiMode(Value: TxBiDiMode);
  288. begin
  289.   FDelphiControl.BiDiMode := TBiDiMode(Value);
  290. end;
  291.  
  292. procedure TTabSetX.Set_Cursor(Value: Smallint);
  293. begin
  294.   FDelphiControl.Cursor := TCursor(Value);
  295. end;
  296.  
  297. procedure TTabSetX.Set_DitherBackground(Value: WordBool);
  298. begin
  299.   FDelphiControl.DitherBackground := Value;
  300. end;
  301.  
  302. procedure TTabSetX.Set_DoubleBuffered(Value: WordBool);
  303. begin
  304.   FDelphiControl.DoubleBuffered := Value;
  305. end;
  306.  
  307. procedure TTabSetX.Set_DragCursor(Value: Smallint);
  308. begin
  309.   FDelphiControl.DragCursor := TCursor(Value);
  310. end;
  311.  
  312. procedure TTabSetX.Set_DragMode(Value: TxDragMode);
  313. begin
  314.   FDelphiControl.DragMode := TDragMode(Value);
  315. end;
  316.  
  317. procedure TTabSetX.Set_Enabled(Value: WordBool);
  318. begin
  319.   FDelphiControl.Enabled := Value;
  320. end;
  321.  
  322. procedure TTabSetX.Set_EndMargin(Value: Integer);
  323. begin
  324.   FDelphiControl.EndMargin := Value;
  325. end;
  326.  
  327. procedure TTabSetX.Set_FirstIndex(Value: Integer);
  328. begin
  329.   FDelphiControl.FirstIndex := Value;
  330. end;
  331.  
  332. procedure TTabSetX.Set_Font(const Value: IFontDisp);
  333. begin
  334.   SetOleFont(FDelphiControl.Font, Value);
  335. end;
  336.  
  337. procedure TTabSetX.Set_SelectedColor(Value: OLE_COLOR);
  338. begin
  339.   FDelphiControl.SelectedColor := TColor(Value);
  340. end;
  341.  
  342. procedure TTabSetX.Set_StartMargin(Value: Integer);
  343. begin
  344.   FDelphiControl.StartMargin := Value;
  345. end;
  346.  
  347. procedure TTabSetX.Set_Style(Value: TxTabStyle);
  348. begin
  349.   FDelphiControl.Style := TTabStyle(Value);
  350. end;
  351.  
  352. procedure TTabSetX.Set_TabHeight(Value: Integer);
  353. begin
  354.   FDelphiControl.TabHeight := Value;
  355. end;
  356.  
  357. procedure TTabSetX.Set_TabIndex(Value: Integer);
  358. begin
  359.   FDelphiControl.TabIndex := Value;
  360. end;
  361.  
  362. procedure TTabSetX.Set_Tabs(const Value: IStrings);
  363. begin
  364.   SetOleStrings(FDelphiControl.Tabs, Value);
  365. end;
  366.  
  367. procedure TTabSetX.Set_UnselectedColor(Value: OLE_COLOR);
  368. begin
  369.   FDelphiControl.UnselectedColor := TColor(Value);
  370. end;
  371.  
  372. procedure TTabSetX.Set_Visible(Value: WordBool);
  373. begin
  374.   FDelphiControl.Visible := Value;
  375. end;
  376.  
  377. procedure TTabSetX.ChangeEvent(Sender: TObject; NewTab: Integer;
  378.   var AllowChange: Boolean);
  379. var
  380.   TempAllowChange: WordBool;
  381. begin
  382.   TempAllowChange := WordBool(AllowChange);
  383.   if FEvents <> nil then FEvents.OnChange(NewTab, TempAllowChange);
  384.   AllowChange := Boolean(TempAllowChange);
  385. end;
  386.  
  387. procedure TTabSetX.ClickEvent(Sender: TObject);
  388. begin
  389.   if FEvents <> nil then FEvents.OnClick;
  390. end;
  391.  
  392. procedure TTabSetX.MeasureTabEvent(Sender: TObject; Index: Integer;
  393.   var TabWidth: Integer);
  394. var
  395.   TempTabWidth: Integer;
  396. begin
  397.   TempTabWidth := Integer(TabWidth);
  398.   if FEvents <> nil then FEvents.OnMeasureTab(Index, TempTabWidth);
  399.   TabWidth := Integer(TempTabWidth);
  400. end;
  401.  
  402. initialization
  403.   TActiveXControlFactory.Create(
  404.     ComServer,
  405.     TTabSetX,
  406.     TTabSet,
  407.     Class_TabSetX,
  408.     35,
  409.     '{695CDBE3-02E5-11D2-B20D-00C04FA368D4}',
  410.     0,
  411.     tmApartment);
  412. end.
  413.