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

  1. unit CGrdImpl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelC_TLB, ColorGrd;
  8.  
  9. type
  10.   TColorGridX = class(TActiveXControl, IColorGridX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TColorGrid;
  14.     FEvents: IColorGridXEvents;
  15.     procedure ChangeEvent(Sender: TObject);
  16.     procedure ClickEvent(Sender: TObject);
  17.     procedure KeyPressEvent(Sender: TObject; var Key: Char);
  18.   protected
  19.     { Protected declarations }
  20.     procedure InitializeControl; override;
  21.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  22.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  23.     function ColorToIndex(AColor: TColor): Integer; safecall;
  24.     function Get_BackgroundColor: TColor; safecall;
  25.     function Get_BackgroundEnabled: WordBool; safecall;
  26.     function Get_BackgroundIndex: Integer; safecall;
  27.     function Get_ClickEnablesColor: WordBool; safecall;
  28.     function Get_Ctl3D: WordBool; safecall;
  29.     function Get_Cursor: Smallint; safecall;
  30.     function Get_DragCursor: Smallint; safecall;
  31.     function Get_DragMode: TxDragMode; safecall;
  32.     function Get_Enabled: WordBool; safecall;
  33.     function Get_Font: Font; safecall;
  34.     function Get_ForegroundColor: TColor; safecall;
  35.     function Get_ForegroundEnabled: WordBool; safecall;
  36.     function Get_ForegroundIndex: Integer; safecall;
  37.     function Get_GridOrdering: TxGridOrdering; safecall;
  38.     function Get_ParentCtl3D: WordBool; safecall;
  39.     function Get_Selection: Integer; safecall;
  40.     function Get_Visible: WordBool; safecall;
  41.     procedure AboutBox; safecall;
  42.     procedure Set_BackgroundEnabled(Value: WordBool); safecall;
  43.     procedure Set_BackgroundIndex(Value: Integer); safecall;
  44.     procedure Set_ClickEnablesColor(Value: WordBool); safecall;
  45.     procedure Set_Ctl3D(Value: WordBool); safecall;
  46.     procedure Set_Cursor(Value: Smallint); safecall;
  47.     procedure Set_DragCursor(Value: Smallint); safecall;
  48.     procedure Set_DragMode(Value: TxDragMode); safecall;
  49.     procedure Set_Enabled(Value: WordBool); safecall;
  50.     procedure Set_Font(const Value: Font); safecall;
  51.     procedure Set_ForegroundEnabled(Value: WordBool); safecall;
  52.     procedure Set_ForegroundIndex(Value: Integer); safecall;
  53.     procedure Set_GridOrdering(Value: TxGridOrdering); safecall;
  54.     procedure Set_ParentCtl3D(Value: WordBool); safecall;
  55.     procedure Set_Selection(Value: Integer); safecall;
  56.     procedure Set_Visible(Value: WordBool); safecall;
  57.   end;
  58.  
  59. implementation
  60.  
  61. uses About6;
  62.  
  63. { TColorGridX }
  64.  
  65. procedure TColorGridX.InitializeControl;
  66. begin
  67.   FDelphiControl := Control as TColorGrid;
  68.   FDelphiControl.OnChange := ChangeEvent;
  69.   FDelphiControl.OnClick := ClickEvent;
  70.   FDelphiControl.OnKeyPress := KeyPressEvent;
  71. end;
  72.  
  73. procedure TColorGridX.EventSinkChanged(const EventSink: IUnknown);
  74. begin
  75.   FEvents := EventSink as IColorGridXEvents;
  76. end;
  77.  
  78. procedure TColorGridX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  79. begin
  80.   { Define property pages here.  Property pages are defined by calling
  81.     DefinePropertyPage with the class id of the page.  For example,
  82.       DefinePropertyPage(Class_ColorGridXPage); }
  83. end;
  84.  
  85. function TColorGridX.ColorToIndex(AColor: TColor): Integer;
  86. begin
  87.   Result := FDelphiControl.ColorToIndex(AColor);
  88. end;
  89.  
  90. function TColorGridX.Get_BackgroundColor: TColor;
  91. begin
  92.   Result := FDelphiControl.BackgroundColor;
  93. end;
  94.  
  95. function TColorGridX.Get_BackgroundEnabled: WordBool;
  96. begin
  97.   Result := FDelphiControl.BackgroundEnabled;
  98. end;
  99.  
  100. function TColorGridX.Get_BackgroundIndex: Integer;
  101. begin
  102.   Result := FDelphiControl.BackgroundIndex;
  103. end;
  104.  
  105. function TColorGridX.Get_ClickEnablesColor: WordBool;
  106. begin
  107.   Result := FDelphiControl.ClickEnablesColor;
  108. end;
  109.  
  110. function TColorGridX.Get_Ctl3D: WordBool;
  111. begin
  112.   Result := FDelphiControl.Ctl3D;
  113. end;
  114.  
  115. function TColorGridX.Get_Cursor: Smallint;
  116. begin
  117.   Result := Smallint(FDelphiControl.Cursor);
  118. end;
  119.  
  120. function TColorGridX.Get_DragCursor: Smallint;
  121. begin
  122.   Result := Smallint(FDelphiControl.DragCursor);
  123. end;
  124.  
  125. function TColorGridX.Get_DragMode: TxDragMode;
  126. begin
  127.   Result := Ord(FDelphiControl.DragMode);
  128. end;
  129.  
  130. function TColorGridX.Get_Enabled: WordBool;
  131. begin
  132.   Result := FDelphiControl.Enabled;
  133. end;
  134.  
  135. function TColorGridX.Get_Font: Font;
  136. begin
  137.   GetOleFont(FDelphiControl.Font, Result);
  138. end;
  139.  
  140. function TColorGridX.Get_ForegroundColor: TColor;
  141. begin
  142.   Result := FDelphiControl.ForegroundColor;
  143. end;
  144.  
  145. function TColorGridX.Get_ForegroundEnabled: WordBool;
  146. begin
  147.   Result := FDelphiControl.ForegroundEnabled;
  148. end;
  149.  
  150. function TColorGridX.Get_ForegroundIndex: Integer;
  151. begin
  152.   Result := FDelphiControl.ForegroundIndex;
  153. end;
  154.  
  155. function TColorGridX.Get_GridOrdering: TxGridOrdering;
  156. begin
  157.   Result := Ord(FDelphiControl.GridOrdering);
  158. end;
  159.  
  160. function TColorGridX.Get_ParentCtl3D: WordBool;
  161. begin
  162.   Result := FDelphiControl.ParentCtl3D;
  163. end;
  164.  
  165. function TColorGridX.Get_Selection: Integer;
  166. begin
  167.   Result := FDelphiControl.Selection;
  168. end;
  169.  
  170. function TColorGridX.Get_Visible: WordBool;
  171. begin
  172.   Result := FDelphiControl.Visible;
  173. end;
  174.  
  175. procedure TColorGridX.AboutBox;
  176. begin
  177.   ShowColorGridXAbout;
  178. end;
  179.  
  180. procedure TColorGridX.Set_BackgroundEnabled(Value: WordBool);
  181. begin
  182.   FDelphiControl.BackgroundEnabled := Value;
  183. end;
  184.  
  185. procedure TColorGridX.Set_BackgroundIndex(Value: Integer);
  186. begin
  187.   FDelphiControl.BackgroundIndex := Value;
  188. end;
  189.  
  190. procedure TColorGridX.Set_ClickEnablesColor(Value: WordBool);
  191. begin
  192.   FDelphiControl.ClickEnablesColor := Value;
  193. end;
  194.  
  195. procedure TColorGridX.Set_Ctl3D(Value: WordBool);
  196. begin
  197.   FDelphiControl.Ctl3D := Value;
  198. end;
  199.  
  200. procedure TColorGridX.Set_Cursor(Value: Smallint);
  201. begin
  202.   FDelphiControl.Cursor := TCursor(Value);
  203. end;
  204.  
  205. procedure TColorGridX.Set_DragCursor(Value: Smallint);
  206. begin
  207.   FDelphiControl.DragCursor := TCursor(Value);
  208. end;
  209.  
  210. procedure TColorGridX.Set_DragMode(Value: TxDragMode);
  211. begin
  212.   FDelphiControl.DragMode := TDragMode(Value);
  213. end;
  214.  
  215. procedure TColorGridX.Set_Enabled(Value: WordBool);
  216. begin
  217.   FDelphiControl.Enabled := Value;
  218. end;
  219.  
  220. procedure TColorGridX.Set_Font(const Value: Font);
  221. begin
  222.   SetOleFont(FDelphiControl.Font, Value);
  223. end;
  224.  
  225. procedure TColorGridX.Set_ForegroundEnabled(Value: WordBool);
  226. begin
  227.   FDelphiControl.ForegroundEnabled := Value;
  228. end;
  229.  
  230. procedure TColorGridX.Set_ForegroundIndex(Value: Integer);
  231. begin
  232.   FDelphiControl.ForegroundIndex := Value;
  233. end;
  234.  
  235. procedure TColorGridX.Set_GridOrdering(Value: TxGridOrdering);
  236. begin
  237.   FDelphiControl.GridOrdering := TGridOrdering(Value);
  238. end;
  239.  
  240. procedure TColorGridX.Set_ParentCtl3D(Value: WordBool);
  241. begin
  242.   FDelphiControl.ParentCtl3D := Value;
  243. end;
  244.  
  245. procedure TColorGridX.Set_Selection(Value: Integer);
  246. begin
  247.   FDelphiControl.Selection := Value;
  248. end;
  249.  
  250. procedure TColorGridX.Set_Visible(Value: WordBool);
  251. begin
  252.   FDelphiControl.Visible := Value;
  253. end;
  254.  
  255. procedure TColorGridX.ChangeEvent(Sender: TObject);
  256. begin
  257.   if FEvents <> nil then FEvents.OnChange;
  258. end;
  259.  
  260. procedure TColorGridX.ClickEvent(Sender: TObject);
  261. begin
  262.   if FEvents <> nil then FEvents.OnClick;
  263. end;
  264.  
  265. procedure TColorGridX.KeyPressEvent(Sender: TObject; var Key: Char);
  266. var
  267.   TempKey: Smallint;
  268. begin
  269.   TempKey := Smallint(Key);
  270.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  271.   Key := Char(TempKey);
  272. end;
  273.  
  274. initialization
  275.   TActiveXControlFactory.Create(
  276.     ComServer,
  277.     TColorGridX,
  278.     TColorGrid,
  279.     Class_ColorGridX,
  280.     6,
  281.     '{FA7B831D-9ED7-11D0-AA40-444553540000}',
  282.     0);
  283. end.
  284.