📄 uphotomgr.pas
字号:
unit uPhotoMgr;
interface
uses
Windows, Messages, SysUtils, Graphics, Forms, Dialogs, Controls, classes
, uInterface;
type
TPhotoMgr = class(TObject, IPhotoMgr)
private
flist: TInterfaceList;
private
//实现IUnknown接口
function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
//实现IPhotoMgr接口
function GetPhotoCount(var Count:Integer):Boolean;
function GetPhotoID(const idx:Integer; var PhotoID:Integer):Boolean;
function GetSelPhotoID(var PhotoID:Integer):Boolean;
function GetPhotoPorp(const photoID:Integer;var PhotoProp:TPhotoProp):Boolean;
function GetBmp(const PhotoID:Integer;var bmp:TBitmap):Boolean;
//事件通知
function SelPhoto(const photoID:Integer):Boolean;
function NewPhoto(const photoID:Integer):Boolean;
function DelPhoto(const photoID:Integer):Boolean;
function Refresh():Boolean;
function PropChange(const photoID:Integer):Boolean;
public
constructor Create;
destructor destroy;override;
//加入通知接口
procedure AddNotify(notify:IPhotoNotify);
procedure Newp;
end;
implementation
{ TPhotoMgr }
constructor TPhotoMgr.Create;
begin
flist := TInterfaceList.Create;
_AddRef;
end;
{------------------------------------------------------------------------------}
destructor TPhotoMgr.destroy;
begin
flist.Free;
inherited;
end;
{//////////////////////////////////////////////////////////////////////////////}
procedure TPhotoMgr.AddNotify(notify: IPhotoNotify);
begin
flist.Add(notify);
end;
{//////////////////////////////////////////////////////////////////////////////}
//实现IUNKnown接口
function TPhotoMgr._AddRef: Integer;
begin
Result := -1;
end;
{------------------------------------------------------------------------------}
function TPhotoMgr._Release: Integer;
begin
Result := -1;
end;
{------------------------------------------------------------------------------}
function TPhotoMgr.QueryInterface(const IID: TGUID; out Obj): HResult;
begin
if GetInterface(IID, Obj) then
Result := 0
else
Result := E_NOINTERFACE;
end;
{//////////////////////////////////////////////////////////////////////////////}
//实现IPhotoMgr接口
function TPhotoMgr.GetBmp(const PhotoID: Integer; var bmp: TBitmap): Boolean;
begin
end;
{------------------------------------------------------------------------------}
function TPhotoMgr.GetPhotoCount(var Count: Integer): Boolean;
begin
Count := 100;
Result := True;
end;
function TPhotoMgr.GetPhotoID(const idx: Integer; var PhotoID: Integer): Boolean;
begin
end;
function TPhotoMgr.GetPhotoPorp(const photoID: Integer; var PhotoProp: TPhotoProp): Boolean;
begin
end;
function TPhotoMgr.GetSelPhotoID(var PhotoID: Integer): Boolean;
begin
end;
{//////////////////////////////////////////////////////////////////////////////}
//发送事件通知
function TPhotoMgr.DelPhoto(const photoID: Integer): Boolean;
var
i:Integer;
begin
Result := False;
if flist.Count = 0 then Exit;
for i := 0 to flist.Count -1 do
begin
if not IPhotoNotify(flist.Items[i]).DelPhoto(photoID) then
Break;
end;
end;
{------------------------------------------------------------------------------}
function TPhotoMgr.NewPhoto(const photoID: Integer): Boolean;
var
i:Integer;
begin
Result := False;
if flist.Count = 0 then Exit;
for i := 0 to flist.Count -1 do
begin
if not IPhotoNotify(flist.items[i]).NewPhoto(photoID) then
Break;
end;
end;
{------------------------------------------------------------------------------}
function TPhotoMgr.PropChange(const photoID: Integer): Boolean;
var
i:Integer;
begin
Result := False;
if flist.Count = 0 then Exit;
for i := 0 to flist.Count -1 do
begin
if not IPhotoNotify(flist.items[i]).PropChange(photoID) then
Break;
end;
end;
{------------------------------------------------------------------------------}
function TPhotoMgr.Refresh: Boolean;
var
i:Integer;
begin
Result := False;
if flist.Count = 0 then Exit;
for i := 0 to flist.Count -1 do
begin
if not IPhotoNotify(flist.items[i]).Refresh then
Break;
end;
end;
{------------------------------------------------------------------------------}
function TPhotoMgr.SelPhoto(const photoID: Integer): Boolean;
var
i:Integer;
begin
Result := False;
if flist.Count = 0 then Exit;
for i := 0 to flist.Count -1 do
begin
if not IPhotoNotify(flist.items[i]).SelPhoto(photoID) then
Break;
end;
end;
{------------------------------------------------------------------------------}
procedure TPhotoMgr.Newp;
begin
NewPhoto(12345);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -