⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clbx_tlb.pas

📁 详细讲述如何用delphi进行com编程
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    property Style: TxListBoxStyle read Get_Style write Set_Style;
    property TabWidth: Integer read Get_TabWidth write Set_TabWidth;
    property Visible: WordBool read Get_Visible write Set_Visible;
    property ItemIndex: Integer read Get_ItemIndex write Set_ItemIndex;
    property SelCount: Integer read Get_SelCount;
    property TopIndex: Integer read Get_TopIndex write Set_TopIndex;
    property DoubleBuffered: WordBool read Get_DoubleBuffered write Set_DoubleBuffered;
    property VisibleDockClientCount: Integer read Get_VisibleDockClientCount;
    property Cursor: Smallint read Get_Cursor write Set_Cursor;
  end;

// *********************************************************************//
// DispIntf:  ICheckListBoxXDisp
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {3774F16E-5D73-11D3-B872-0040F67455FE}
// *********************************************************************//
  ICheckListBoxXDisp = dispinterface
    ['{3774F16E-5D73-11D3-B872-0040F67455FE}']
    property AllowGrayed: WordBool dispid 1;
    property BorderStyle: TxBorderStyle dispid 2;
    property Color: OLE_COLOR dispid -501;
    property Columns: Integer dispid 3;
    property Ctl3D: WordBool dispid 4;
    property DragCursor: Smallint dispid 5;
    property DragMode: TxDragMode dispid 6;
    property Enabled: WordBool dispid -514;
    property Flat: WordBool dispid 7;
    property Font: IFontDisp dispid -512;
    property ImeMode: TxImeMode dispid 8;
    property ImeName: WideString dispid 9;
    property IntegralHeight: WordBool dispid 10;
    property ItemHeight: Integer dispid 11;
    property Items: IStrings dispid 12;
    property ParentColor: WordBool dispid 13;
    property ParentCtl3D: WordBool dispid 14;
    property Sorted: WordBool dispid 15;
    property Style: TxListBoxStyle dispid 16;
    property TabWidth: Integer dispid 17;
    property Visible: WordBool dispid 18;
    property ItemIndex: Integer dispid 21;
    property SelCount: Integer readonly dispid 22;
    property TopIndex: Integer dispid 23;
    property DoubleBuffered: WordBool dispid 24;
    property VisibleDockClientCount: Integer readonly dispid 25;
    property Cursor: Smallint dispid 34;
    procedure AboutBox; dispid -552;
  end;

// *********************************************************************//
// DispIntf:  ICheckListBoxXEvents
// Flags:     (4096) Dispatchable
// GUID:      {3774F170-5D73-11D3-B872-0040F67455FE}
// *********************************************************************//
  ICheckListBoxXEvents = dispinterface
    ['{3774F170-5D73-11D3-B872-0040F67455FE}']
    procedure OnClickCheck; dispid 1;
    procedure OnClick; dispid 2;
    procedure OnDblClick; dispid 4;
    procedure OnKeyPress(var Key: Smallint); dispid 11;
  end;


// *********************************************************************//
// OLE Control Proxy class declaration
// Control Name     : TCheckListBoxX
// Help String      : CheckListBoxX Control
// Default Interface: ICheckListBoxX
// Def. Intf. DISP? : No
// Event   Interface: ICheckListBoxXEvents
// TypeFlags        : (38) CanCreate Licensed Control
// *********************************************************************//
  TCheckListBoxXOnKeyPress = procedure(Sender: TObject; var Key: Smallint) of object;

  TCheckListBoxX = class(TOleControl)
  private
    FOnClickCheck: TNotifyEvent;
    FOnClick: TNotifyEvent;
    FOnDblClick: TNotifyEvent;
    FOnKeyPress: TCheckListBoxXOnKeyPress;
    FIntf: ICheckListBoxX;
    function  GetControlInterface: ICheckListBoxX;
  protected
    procedure CreateControl;
    procedure InitControlData; override;
    function  Get_Items: IStrings;
    procedure Set_Items(const Value: IStrings);
  public
    procedure AboutBox;
    property  ControlInterface: ICheckListBoxX read GetControlInterface;
    property  DefaultInterface: ICheckListBoxX read GetControlInterface;
    property ItemIndex: Integer index 21 read GetIntegerProp write SetIntegerProp;
    property SelCount: Integer index 22 read GetIntegerProp;
    property TopIndex: Integer index 23 read GetIntegerProp write SetIntegerProp;
    property DoubleBuffered: WordBool index 24 read GetWordBoolProp write SetWordBoolProp;
    property VisibleDockClientCount: Integer index 25 read GetIntegerProp;
  published
    property  ParentFont;
    property  TabStop;
    property  Align;
    property  ParentShowHint;
    property  PopupMenu;
    property  ShowHint;
    property  TabOrder;
    property  OnDragDrop;
    property  OnDragOver;
    property  OnEndDrag;
    property  OnEnter;
    property  OnExit;
    property  OnStartDrag;
    property AllowGrayed: WordBool index 1 read GetWordBoolProp write SetWordBoolProp stored False;
    property BorderStyle: TOleEnum index 2 read GetTOleEnumProp write SetTOleEnumProp stored False;
    property Color: TColor index -501 read GetTColorProp write SetTColorProp stored False;
    property Columns: Integer index 3 read GetIntegerProp write SetIntegerProp stored False;
    property Ctl3D: WordBool index 4 read GetWordBoolProp write SetWordBoolProp stored False;
    property DragCursor: Smallint index 5 read GetSmallintProp write SetSmallintProp stored False;
    property DragMode: TOleEnum index 6 read GetTOleEnumProp write SetTOleEnumProp stored False;
    property Enabled: WordBool index -514 read GetWordBoolProp write SetWordBoolProp stored False;
    property Flat: WordBool index 7 read GetWordBoolProp write SetWordBoolProp stored False;
    property Font: TFont index -512 read GetTFontProp write SetTFontProp stored False;
    property ImeMode: TOleEnum index 8 read GetTOleEnumProp write SetTOleEnumProp stored False;
    property ImeName: WideString index 9 read GetWideStringProp write SetWideStringProp stored False;
    property IntegralHeight: WordBool index 10 read GetWordBoolProp write SetWordBoolProp stored False;
    property ItemHeight: Integer index 11 read GetIntegerProp write SetIntegerProp stored False;
    property Items: IStrings read Get_Items write Set_Items stored False;
    property ParentColor: WordBool index 13 read GetWordBoolProp write SetWordBoolProp stored False;
    property ParentCtl3D: WordBool index 14 read GetWordBoolProp write SetWordBoolProp stored False;
    property Sorted: WordBool index 15 read GetWordBoolProp write SetWordBoolProp stored False;
    property Style: TOleEnum index 16 read GetTOleEnumProp write SetTOleEnumProp stored False;
    property TabWidth: Integer index 17 read GetIntegerProp write SetIntegerProp stored False;
    property Visible: WordBool index 18 read GetWordBoolProp write SetWordBoolProp stored False;
    property Cursor: Smallint index 34 read GetSmallintProp write SetSmallintProp stored False;
    property OnClickCheck: TNotifyEvent read FOnClickCheck write FOnClickCheck;
    property OnClick: TNotifyEvent read FOnClick write FOnClick;
    property OnDblClick: TNotifyEvent read FOnDblClick write FOnDblClick;
    property OnKeyPress: TCheckListBoxXOnKeyPress read FOnKeyPress write FOnKeyPress;
  end;

procedure Register;

implementation

uses ComObj;

procedure TCheckListBoxX.InitControlData;
const
  CEventDispIDs: array [0..3] of DWORD = (
    $00000001, $00000002, $00000004, $0000000B);
  CLicenseKey: array[0..38] of Word = ( $007B, $0033, $0037, $0037, $0034, $0046, $0031, $0037, $0039, $002D, $0035
    , $0044, $0037, $0033, $002D, $0031, $0031, $0044, $0033, $002D, $0042
    , $0038, $0037, $0032, $002D, $0030, $0030, $0034, $0030, $0046, $0036
    , $0037, $0034, $0035, $0035, $0046, $0045, $007D, $0000);
  CTFontIDs: array [0..0] of DWORD = (
    $FFFFFE00);
  CControlData: TControlData2 = (
    ClassID: '{3774F172-5D73-11D3-B872-0040F67455FE}';
    EventIID: '{3774F170-5D73-11D3-B872-0040F67455FE}';
    EventCount: 4;
    EventDispIDs: @CEventDispIDs;
    LicenseKey: @CLicenseKey;
    Flags: $0000000D;
    Version: 401;
    FontCount: 1;
    FontIDs: @CTFontIDs);
begin
  ControlData := @CControlData;
  TControlData2(CControlData).FirstEventOfs := Cardinal(@@FOnClickCheck) - Cardinal(Self);
end;

procedure TCheckListBoxX.CreateControl;

  procedure DoCreate;
  begin
    FIntf := IUnknown(OleObject) as ICheckListBoxX;
  end;

begin
  if FIntf = nil then DoCreate;
end;

function TCheckListBoxX.GetControlInterface: ICheckListBoxX;
begin
  CreateControl;
  Result := FIntf;
end;

function  TCheckListBoxX.Get_Items: IStrings;
begin
  Result := DefaultInterface.Get_Items;
end;

procedure TCheckListBoxX.Set_Items(const Value: IStrings);
begin
  DefaultInterface.Set_Items(Value);
end;

procedure TCheckListBoxX.AboutBox;
begin
  DefaultInterface.AboutBox;
end;

procedure Register;
begin
  RegisterComponents('ActiveX',[TCheckListBoxX]);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -