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

  1. unit CheckListBoxImpl1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelCtrls_TLB, CheckLst;
  8.  
  9. type
  10.   TCheckListBoxX = class(TActiveXControl, ICheckListBoxX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TCheckListBox;
  14.     FEvents: ICheckListBoxXEvents;
  15.     procedure ClickCheckEvent(Sender: TObject);
  16.     procedure ClickEvent(Sender: TObject);
  17.     procedure DblClickEvent(Sender: TObject);
  18.     procedure KeyPressEvent(Sender: TObject; var Key: Char);
  19.     procedure MeasureItemEvent(Control: TWinControl; Index: Integer;
  20.       var Height: Integer);
  21.   protected
  22.     { Protected declarations }
  23.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  24.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  25.     procedure InitializeControl; override;
  26.     function ClassNameIs(const Name: WideString): WordBool; safecall;
  27.     function DrawTextBiDiModeFlags(Flags: Integer): Integer; safecall;
  28.     function DrawTextBiDiModeFlagsReadingOnly: Integer; safecall;
  29.     function Get_AllowGrayed: WordBool; safecall;
  30.     function Get_BiDiMode: TxBiDiMode; safecall;
  31.     function Get_BorderStyle: TxBorderStyle; safecall;
  32.     function Get_Color: OLE_COLOR; safecall;
  33.     function Get_Columns: Integer; safecall;
  34.     function Get_Ctl3D: WordBool; safecall;
  35.     function Get_Cursor: Smallint; safecall;
  36.     function Get_DoubleBuffered: WordBool; safecall;
  37.     function Get_DragCursor: Smallint; safecall;
  38.     function Get_DragMode: TxDragMode; safecall;
  39.     function Get_Enabled: WordBool; safecall;
  40.     function Get_Flat: WordBool; safecall;
  41.     function Get_Font: IFontDisp; safecall;
  42.     function Get_ImeMode: TxImeMode; safecall;
  43.     function Get_ImeName: WideString; safecall;
  44.     function Get_IntegralHeight: WordBool; safecall;
  45.     function Get_ItemHeight: Integer; safecall;
  46.     function Get_ItemIndex: Integer; safecall;
  47.     function Get_Items: IStrings; safecall;
  48.     function Get_ParentColor: WordBool; safecall;
  49.     function Get_ParentCtl3D: WordBool; safecall;
  50.     function Get_ParentFont: WordBool; safecall;
  51.     function Get_SelCount: Integer; safecall;
  52.     function Get_Sorted: WordBool; safecall;
  53.     function Get_Style: TxListBoxStyle; safecall;
  54.     function Get_TabWidth: Integer; safecall;
  55.     function Get_TopIndex: Integer; safecall;
  56.     function Get_Visible: WordBool; safecall;
  57.     function GetControlsAlignment: TxAlignment; safecall;
  58.     function IsRightToLeft: WordBool; safecall;
  59.     function UseRightToLeftAlignment: WordBool; safecall;
  60.     function UseRightToLeftReading: WordBool; safecall;
  61.     function UseRightToLeftScrollBar: WordBool; safecall;
  62.     procedure _Set_Font(const Value: IFontDisp); safecall;
  63.     procedure AboutBox; safecall;
  64.     procedure Clear; safecall;
  65.     procedure FlipChildren(AllLevels: WordBool); safecall;
  66.     procedure InitiateAction; safecall;
  67.     procedure Set_AllowGrayed(Value: WordBool); safecall;
  68.     procedure Set_BiDiMode(Value: TxBiDiMode); safecall;
  69.     procedure Set_BorderStyle(Value: TxBorderStyle); safecall;
  70.     procedure Set_Color(Value: OLE_COLOR); safecall;
  71.     procedure Set_Columns(Value: Integer); safecall;
  72.     procedure Set_Ctl3D(Value: WordBool); safecall;
  73.     procedure Set_Cursor(Value: Smallint); safecall;
  74.     procedure Set_DoubleBuffered(Value: WordBool); safecall;
  75.     procedure Set_DragCursor(Value: Smallint); safecall;
  76.     procedure Set_DragMode(Value: TxDragMode); safecall;
  77.     procedure Set_Enabled(Value: WordBool); safecall;
  78.     procedure Set_Flat(Value: WordBool); safecall;
  79.     procedure Set_Font(const Value: IFontDisp); safecall;
  80.     procedure Set_ImeMode(Value: TxImeMode); safecall;
  81.     procedure Set_ImeName(const Value: WideString); safecall;
  82.     procedure Set_IntegralHeight(Value: WordBool); safecall;
  83.     procedure Set_ItemHeight(Value: Integer); safecall;
  84.     procedure Set_ItemIndex(Value: Integer); safecall;
  85.     procedure Set_Items(const Value: IStrings); safecall;
  86.     procedure Set_ParentColor(Value: WordBool); safecall;
  87.     procedure Set_ParentCtl3D(Value: WordBool); safecall;
  88.     procedure Set_ParentFont(Value: WordBool); safecall;
  89.     procedure Set_Sorted(Value: WordBool); safecall;
  90.     procedure Set_Style(Value: TxListBoxStyle); safecall;
  91.     procedure Set_TabWidth(Value: Integer); safecall;
  92.     procedure Set_TopIndex(Value: Integer); safecall;
  93.     procedure Set_Visible(Value: WordBool); safecall;
  94.   end;
  95.  
  96. implementation
  97.  
  98. uses ComObj, About5;
  99.  
  100. { TCheckListBoxX }
  101.  
  102. procedure TCheckListBoxX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  103. begin
  104.   { Define property pages here.  Property pages are defined by calling
  105.     DefinePropertyPage with the class id of the page.  For example,
  106.       DefinePropertyPage(Class_CheckListBoxXPage); }
  107. end;
  108.  
  109. procedure TCheckListBoxX.EventSinkChanged(const EventSink: IUnknown);
  110. begin
  111.   FEvents := EventSink as ICheckListBoxXEvents;
  112. end;
  113.  
  114. procedure TCheckListBoxX.InitializeControl;
  115. begin
  116.   FDelphiControl := Control as TCheckListBox;
  117.   FDelphiControl.OnClick := ClickEvent;
  118.   FDelphiControl.OnClickCheck := ClickCheckEvent;
  119.   FDelphiControl.OnDblClick := DblClickEvent;
  120.   FDelphiControl.OnKeyPress := KeyPressEvent;
  121.   FDelphiControl.OnMeasureItem := MeasureItemEvent;
  122. end;
  123.  
  124. function TCheckListBoxX.ClassNameIs(const Name: WideString): WordBool;
  125. begin
  126.   Result := FDelphiControl.ClassNameIs(Name);
  127. end;
  128.  
  129. function TCheckListBoxX.DrawTextBiDiModeFlags(Flags: Integer): Integer;
  130. begin
  131.   Result := FDelphiControl.DrawTextBiDiModeFlags(Flags);
  132. end;
  133.  
  134. function TCheckListBoxX.DrawTextBiDiModeFlagsReadingOnly: Integer;
  135. begin
  136.   Result := FDelphiControl.DrawTextBiDiModeFlagsReadingOnly;
  137. end;
  138.  
  139. function TCheckListBoxX.Get_AllowGrayed: WordBool;
  140. begin
  141.   Result := FDelphiControl.AllowGrayed;
  142. end;
  143.  
  144. function TCheckListBoxX.Get_BiDiMode: TxBiDiMode;
  145. begin
  146.   Result := Ord(FDelphiControl.BiDiMode);
  147. end;
  148.  
  149. function TCheckListBoxX.Get_BorderStyle: TxBorderStyle;
  150. begin
  151.   Result := Ord(FDelphiControl.BorderStyle);
  152. end;
  153.  
  154. function TCheckListBoxX.Get_Color: OLE_COLOR;
  155. begin
  156.   Result := OLE_COLOR(FDelphiControl.Color);
  157. end;
  158.  
  159. function TCheckListBoxX.Get_Columns: Integer;
  160. begin
  161.   Result := FDelphiControl.Columns;
  162. end;
  163.  
  164. function TCheckListBoxX.Get_Ctl3D: WordBool;
  165. begin
  166.   Result := FDelphiControl.Ctl3D;
  167. end;
  168.  
  169. function TCheckListBoxX.Get_Cursor: Smallint;
  170. begin
  171.   Result := Smallint(FDelphiControl.Cursor);
  172. end;
  173.  
  174. function TCheckListBoxX.Get_DoubleBuffered: WordBool;
  175. begin
  176.   Result := FDelphiControl.DoubleBuffered;
  177. end;
  178.  
  179. function TCheckListBoxX.Get_DragCursor: Smallint;
  180. begin
  181.   Result := Smallint(FDelphiControl.DragCursor);
  182. end;
  183.  
  184. function TCheckListBoxX.Get_DragMode: TxDragMode;
  185. begin
  186.   Result := Ord(FDelphiControl.DragMode);
  187. end;
  188.  
  189. function TCheckListBoxX.Get_Enabled: WordBool;
  190. begin
  191.   Result := FDelphiControl.Enabled;
  192. end;
  193.  
  194. function TCheckListBoxX.Get_Flat: WordBool;
  195. begin
  196.   Result := FDelphiControl.Flat;
  197. end;
  198.  
  199. function TCheckListBoxX.Get_Font: IFontDisp;
  200. begin
  201.   GetOleFont(FDelphiControl.Font, Result);
  202. end;
  203.  
  204. function TCheckListBoxX.Get_ImeMode: TxImeMode;
  205. begin
  206.   Result := Ord(FDelphiControl.ImeMode);
  207. end;
  208.  
  209. function TCheckListBoxX.Get_ImeName: WideString;
  210. begin
  211.   Result := WideString(FDelphiControl.ImeName);
  212. end;
  213.  
  214. function TCheckListBoxX.Get_IntegralHeight: WordBool;
  215. begin
  216.   Result := FDelphiControl.IntegralHeight;
  217. end;
  218.  
  219. function TCheckListBoxX.Get_ItemHeight: Integer;
  220. begin
  221.   Result := FDelphiControl.ItemHeight;
  222. end;
  223.  
  224. function TCheckListBoxX.Get_ItemIndex: Integer;
  225. begin
  226.   Result := FDelphiControl.ItemIndex;
  227. end;
  228.  
  229. function TCheckListBoxX.Get_Items: IStrings;
  230. begin
  231.   GetOleStrings(FDelphiControl.Items, Result);
  232. end;
  233.  
  234. function TCheckListBoxX.Get_ParentColor: WordBool;
  235. begin
  236.   Result := FDelphiControl.ParentColor;
  237. end;
  238.  
  239. function TCheckListBoxX.Get_ParentCtl3D: WordBool;
  240. begin
  241.   Result := FDelphiControl.ParentCtl3D;
  242. end;
  243.  
  244. function TCheckListBoxX.Get_ParentFont: WordBool;
  245. begin
  246.   Result := FDelphiControl.ParentFont;
  247. end;
  248.  
  249. function TCheckListBoxX.Get_SelCount: Integer;
  250. begin
  251.   Result := FDelphiControl.SelCount;
  252. end;
  253.  
  254. function TCheckListBoxX.Get_Sorted: WordBool;
  255. begin
  256.   Result := FDelphiControl.Sorted;
  257. end;
  258.  
  259. function TCheckListBoxX.Get_Style: TxListBoxStyle;
  260. begin
  261.   Result := Ord(FDelphiControl.Style);
  262. end;
  263.  
  264. function TCheckListBoxX.Get_TabWidth: Integer;
  265. begin
  266.   Result := FDelphiControl.TabWidth;
  267. end;
  268.  
  269. function TCheckListBoxX.Get_TopIndex: Integer;
  270. begin
  271.   Result := FDelphiControl.TopIndex;
  272. end;
  273.  
  274. function TCheckListBoxX.Get_Visible: WordBool;
  275. begin
  276.   Result := FDelphiControl.Visible;
  277. end;
  278.  
  279. function TCheckListBoxX.GetControlsAlignment: TxAlignment;
  280. begin
  281.  Result := TxAlignment(FDelphiControl.GetControlsAlignment);
  282. end;
  283.  
  284. function TCheckListBoxX.IsRightToLeft: WordBool;
  285. begin
  286.   Result := FDelphiControl.IsRightToLeft;
  287. end;
  288.  
  289. function TCheckListBoxX.UseRightToLeftAlignment: WordBool;
  290. begin
  291.   Result := FDelphiControl.UseRightToLeftAlignment;
  292. end;
  293.  
  294. function TCheckListBoxX.UseRightToLeftReading: WordBool;
  295. begin
  296.   Result := FDelphiControl.UseRightToLeftReading;
  297. end;
  298.  
  299. function TCheckListBoxX.UseRightToLeftScrollBar: WordBool;
  300. begin
  301.   Result := FDelphiControl.UseRightToLeftScrollBar;
  302. end;
  303.  
  304. procedure TCheckListBoxX._Set_Font(const Value: IFontDisp);
  305. begin
  306.   SetOleFont(FDelphiControl.Font, Value);
  307. end;
  308.  
  309. procedure TCheckListBoxX.AboutBox;
  310. begin
  311.   ShowCheckListBoxXAbout;
  312. end;
  313.  
  314. procedure TCheckListBoxX.Clear;
  315. begin
  316.   FDelphiControl.Clear;
  317. end;
  318.  
  319. procedure TCheckListBoxX.FlipChildren(AllLevels: WordBool);
  320. begin
  321.   FDelphiControl.FlipChildren(AllLevels);
  322. end;
  323.  
  324. procedure TCheckListBoxX.InitiateAction;
  325. begin
  326.   FDelphiControl.InitiateAction;
  327. end;
  328.  
  329. procedure TCheckListBoxX.Set_AllowGrayed(Value: WordBool);
  330. begin
  331.   FDelphiControl.AllowGrayed := Value;
  332. end;
  333.  
  334. procedure TCheckListBoxX.Set_BiDiMode(Value: TxBiDiMode);
  335. begin
  336.   FDelphiControl.BiDiMode := TBiDiMode(Value);
  337. end;
  338.  
  339. procedure TCheckListBoxX.Set_BorderStyle(Value: TxBorderStyle);
  340. begin
  341.   FDelphiControl.BorderStyle := TBorderStyle(Value);
  342. end;
  343.  
  344. procedure TCheckListBoxX.Set_Color(Value: OLE_COLOR);
  345. begin
  346.   FDelphiControl.Color := TColor(Value);
  347. end;
  348.  
  349. procedure TCheckListBoxX.Set_Columns(Value: Integer);
  350. begin
  351.   FDelphiControl.Columns := Value;
  352. end;
  353.  
  354. procedure TCheckListBoxX.Set_Ctl3D(Value: WordBool);
  355. begin
  356.   FDelphiControl.Ctl3D := Value;
  357. end;
  358.  
  359. procedure TCheckListBoxX.Set_Cursor(Value: Smallint);
  360. begin
  361.   FDelphiControl.Cursor := TCursor(Value);
  362. end;
  363.  
  364. procedure TCheckListBoxX.Set_DoubleBuffered(Value: WordBool);
  365. begin
  366.   FDelphiControl.DoubleBuffered := Value;
  367. end;
  368.  
  369. procedure TCheckListBoxX.Set_DragCursor(Value: Smallint);
  370. begin
  371.   FDelphiControl.DragCursor := TCursor(Value);
  372. end;
  373.  
  374. procedure TCheckListBoxX.Set_DragMode(Value: TxDragMode);
  375. begin
  376.   FDelphiControl.DragMode := TDragMode(Value);
  377. end;
  378.  
  379. procedure TCheckListBoxX.Set_Enabled(Value: WordBool);
  380. begin
  381.   FDelphiControl.Enabled := Value;
  382. end;
  383.  
  384. procedure TCheckListBoxX.Set_Flat(Value: WordBool);
  385. begin
  386.   FDelphiControl.Flat := Value;
  387. end;
  388.  
  389. procedure TCheckListBoxX.Set_Font(const Value: IFontDisp);
  390. begin
  391.   SetOleFont(FDelphiControl.Font, Value);
  392. end;
  393.  
  394. procedure TCheckListBoxX.Set_ImeMode(Value: TxImeMode);
  395. begin
  396.   FDelphiControl.ImeMode := TImeMode(Value);
  397. end;
  398.  
  399. procedure TCheckListBoxX.Set_ImeName(const Value: WideString);
  400. begin
  401.   FDelphiControl.ImeName := TImeName(Value);
  402. end;
  403.  
  404. procedure TCheckListBoxX.Set_IntegralHeight(Value: WordBool);
  405. begin
  406.   FDelphiControl.IntegralHeight := Value;
  407. end;
  408.  
  409. procedure TCheckListBoxX.Set_ItemHeight(Value: Integer);
  410. begin
  411.   FDelphiControl.ItemHeight := Value;
  412. end;
  413.  
  414. procedure TCheckListBoxX.Set_ItemIndex(Value: Integer);
  415. begin
  416.   FDelphiControl.ItemIndex := Value;
  417. end;
  418.  
  419. procedure TCheckListBoxX.Set_Items(const Value: IStrings);
  420. begin
  421.   SetOleStrings(FDelphiControl.Items, Value);
  422. end;
  423.  
  424. procedure TCheckListBoxX.Set_ParentColor(Value: WordBool);
  425. begin
  426.   FDelphiControl.ParentColor := Value;
  427. end;
  428.  
  429. procedure TCheckListBoxX.Set_ParentCtl3D(Value: WordBool);
  430. begin
  431.   FDelphiControl.ParentCtl3D := Value;
  432. end;
  433.  
  434. procedure TCheckListBoxX.Set_ParentFont(Value: WordBool);
  435. begin
  436.   FDelphiControl.ParentFont := Value;
  437. end;
  438.  
  439. procedure TCheckListBoxX.Set_Sorted(Value: WordBool);
  440. begin
  441.   FDelphiControl.Sorted := Value;
  442. end;
  443.  
  444. procedure TCheckListBoxX.Set_Style(Value: TxListBoxStyle);
  445. begin
  446.   FDelphiControl.Style := TListBoxStyle(Value);
  447. end;
  448.  
  449. procedure TCheckListBoxX.Set_TabWidth(Value: Integer);
  450. begin
  451.   FDelphiControl.TabWidth := Value;
  452. end;
  453.  
  454. procedure TCheckListBoxX.Set_TopIndex(Value: Integer);
  455. begin
  456.   FDelphiControl.TopIndex := Value;
  457. end;
  458.  
  459. procedure TCheckListBoxX.Set_Visible(Value: WordBool);
  460. begin
  461.   FDelphiControl.Visible := Value;
  462. end;
  463.  
  464. procedure TCheckListBoxX.ClickCheckEvent(Sender: TObject);
  465. begin
  466.   if FEvents <> nil then FEvents.OnClickCheck;
  467. end;
  468.  
  469. procedure TCheckListBoxX.ClickEvent(Sender: TObject);
  470. begin
  471.   if FEvents <> nil then FEvents.OnClick;
  472. end;
  473.  
  474. procedure TCheckListBoxX.DblClickEvent(Sender: TObject);
  475. begin
  476.   if FEvents <> nil then FEvents.OnDblClick;
  477. end;
  478.  
  479. procedure TCheckListBoxX.KeyPressEvent(Sender: TObject; var Key: Char);
  480. var
  481.   TempKey: Smallint;
  482. begin
  483.   TempKey := Smallint(Key);
  484.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  485.   Key := Char(TempKey);
  486. end;
  487.  
  488. procedure TCheckListBoxX.MeasureItemEvent(Control: TWinControl;
  489.   Index: Integer; var Height: Integer);
  490. var
  491.   TempHeight: Integer;
  492. begin
  493.   TempHeight := Integer(Height);
  494.   if FEvents <> nil then FEvents.OnMeasureItem(Index, TempHeight);
  495.   Height := Integer(TempHeight);
  496. end;
  497.  
  498. initialization
  499.   TActiveXControlFactory.Create(
  500.     ComServer,
  501.     TCheckListBoxX,
  502.     TCheckListBox,
  503.     Class_CheckListBoxX,
  504.     5,
  505.     '{695CDAF6-02E5-11D2-B20D-00C04FA368D4}',
  506.     0,
  507.     tmApartment);
  508. end.
  509.