lvitem.pas
来自「《Delphi开发人员指南》配书原码」· PAS 代码 · 共 70 行
PAS
70 行
unit LVItem;
interface
uses
ComObj, ActiveX, ComCtrls, LVCtrl_TLB, StdVcl, AxCtrls;
type
TListItem = class(TAutoIntfObject, IListItem)
private
FListItem: ComCtrls.TListItem;
protected
function Get_Caption: WideString; safecall;
function Get_Index: Integer; safecall;
function Get_SubItems: IStrings; safecall;
procedure Set_Caption(const Value: WideString); safecall;
procedure Set_SubItems(const Value: IStrings); safecall;
function Get_Checked: WordBool; safecall;
procedure Set_Checked(Value: WordBool); safecall;
public
constructor Create(AOwner: ComCtrls.TListItem);
end;
implementation
uses ComServ;
constructor TListItem.Create(AOwner: ComCtrls.TListItem);
begin
inherited Create(ComServer.TypeLib, IListItem);
FListItem := AOwner;
end;
function TListItem.Get_Caption: WideString;
begin
Result := FListItem.Caption;
end;
function TListItem.Get_Index: Integer;
begin
Result := FListItem.Index;
end;
function TListItem.Get_SubItems: IStrings;
begin
GetOleStrings(FListItem.SubItems, Result);
end;
procedure TListItem.Set_Caption(const Value: WideString);
begin
FListItem.Caption := Value;
end;
procedure TListItem.Set_SubItems(const Value: IStrings);
begin
SetOleStrings(FListItem.SubItems, Value);
end;
function TListItem.Get_Checked: WordBool;
begin
Result := FListItem.Checked;
end;
procedure TListItem.Set_Checked(Value: WordBool);
begin
FListItem.Checked := Value;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?