Delphi 深入浅出VCL(4)

Stella981
• 阅读 937

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

TComponent = class(TPersistent, IInterface, IInterfaceComponentReference)
  protected type
    TComponentAsyncResult = class(TBaseAsyncResult)
    private
      FComponent: TComponent;
    protected
      procedure Schedule; override;
      constructor Create(const AContext: TObject; const AComponent: TComponent);
    end;
    TAsyncConstArrayResult = class(TComponentASyncResult)
    protected
      FParams: TArray<TValue>;
      constructor Create(const AContext: TObject; const AComponent: TComponent; const Params: array of const);
    end;
    TAsyncConstArrayProcResult = class sealed(TAsyncConstArrayResult)
    private
      FAsyncProcedure: TAsyncConstArrayProc;
    protected
      procedure AsyncDispatch; override;
      constructor Create(const AAsyncProcedure: TAsyncConstArrayProc; const AContext: TObject; const AComponent: TComponent; const Params: array of const);
    end;
    TAsyncConstArrayFuncResult<TResult> = class sealed(TAsyncConstArrayResult)
    private
      FRetVal: TResult;
      FAsyncFunction: TAsyncConstArrayFunc<TResult>;
    protected
      constructor Create(const AAsyncFunction: TAsyncConstArrayFunc<TResult>; const AContext: TObject; const AComponent: TComponent; const Params: array of const);
      procedure AsyncDispatch; override;
      function GetRetVal: TResult;
    end;
    TAsyncConstArrayProcedureResult = class sealed(TAsyncConstArrayResult)
    private
      FAsyncProcedure: TAsyncConstArrayProcedureEvent;
    protected
      procedure AsyncDispatch; override;
      constructor Create(const AAsyncProcedure: TAsyncConstArrayProcedureEvent; const AContext: TObject; const AComponent: TComponent; const Params: array of const);
    end;
    TAsyncConstArrayFunctionResult = class sealed(TAsyncConstArrayResult)
    private
      FRetVal: TObject;
      FAsyncFunction: TAsyncConstArrayFunctionEvent;
    protected
      constructor Create(const AAsyncFunction: TAsyncConstArrayFunctionEvent; const AContext: TObject; const AComponent: TComponent; const Params: array of const);
      procedure AsyncDispatch; override;
      function GetRetVal: TObject;
    end;
    TAsyncProcedureResult = class sealed(TComponentAsyncResult)
    private
      FAsyncProcedure: TProc;
    protected
      constructor Create(const AAsyncProcedure: TProc; const AContext: TObject; const AComponent: TComponent);// overload;
      procedure AsyncDispatch; override;
    end;
    TAsyncFunctionResult<TResult> = class sealed(TComponentAsyncResult)
    private
      FRetVal: TResult;
      FAsyncFunction: TFunc<TResult>;
    protected
      constructor Create(const AAsyncFunction: TFunc<TResult>; const AContext: TObject; const AComponent: TComponent);// overload;
      procedure AsyncDispatch; override;
      function GetRetVal: TResult;
    end;
    TAsyncProcedureResultEvent = class sealed(TComponentAsyncResult)
    private
      FAsyncProcedure: TAsyncProcedureEvent;
    protected
      constructor Create(const AAsyncProcedure: TAsyncProcedureEvent; const AContext: TObject; const AComponent: TComponent);// overload;
      procedure AsyncDispatch; override;
    end;
    TAsyncFunctionResultEvent = class sealed(TComponentAsyncResult)
    private
      FRetVal: TObject;
      FAsyncFunction: TAsyncFunctionEvent;
    protected
      constructor Create(const AAsyncFunction: TAsyncFunctionEvent; const AContext: TObject; const AComponent: TComponent);// overload;
      procedure AsyncDispatch; override;
      function GetRetVal: TObject;
    end;
  private
    [Unsafe] FOwner: TComponent;
    FName: TComponentName;
    FTag: NativeInt;
    FComponents: TList<TComponent>;
    FFreeNotifies: TList<TComponent>;
                                                                                      
    FDesignInfo: TDesignInfo;
    FComponentState: TComponentState;
    FVCLComObject: Pointer;
    FObservers: TObservers;
    FOnGetDeltaStreams: TGetDeltaStreamsEvent;
    function GetComObject: IUnknown;
    function GetComponent(AIndex: Integer): TComponent;
    function GetComponentCount: Integer;
    function GetComponentIndex: Integer;
    procedure Insert(AComponent: TComponent);
    procedure ReadLeft(Reader: TReader);
    procedure ReadTop(Reader: TReader);
    procedure Remove(AComponent: TComponent);
    procedure RemoveNotification(const AComponent: TComponent);
    procedure SetComponentIndex(Value: Integer);
    procedure SetReference(Enable: Boolean);
    procedure WriteLeft(Writer: TWriter);
    procedure WriteTop(Writer: TWriter);
    { IInterfaceComponentReference }
    function IInterfaceComponentReference.GetComponent = IntfGetComponent;
    function IntfGetComponent: TComponent;
    procedure DoGetDeltaStreams(Proc: TGetStreamProc; var Handled: Boolean);
    procedure ReadDeltaStream(const S: TStream);
    procedure ReadDeltaState;
  protected
    FComponentStyle: TComponentStyle;
  private
    FSortedComponents: TList<TComponent>;
    function FindSortedComponent(const AName: string; var Index: Integer): TComponent;
    procedure AddSortedComponent(const AComponent: TComponent);
    procedure RemoveSortedComponent(const AComponent: TComponent); inline;
  private class var
    FComparer: IComparer<TComponent>;
    class constructor Create;
  protected
    /// <summary>
    ///    Override AsyncSchedule in descendant components in order to modify the manner in which an async method
    ///    call should be scheduled. By default, this will queue the method call with the main thread using
    ///    TThread.Queue.
    /// </summary>
    procedure AsyncSchedule(const ASyncResult: TBaseAsyncResult); virtual;
    procedure ChangeName(const NewName: TComponentName);
    procedure DefineProperties(Filer: TFiler); override;
    procedure GetChildren(Proc: TGetChildProc; Root: TComponent); dynamic;
    function GetChildOwner: TComponent; dynamic;
    function GetChildParent: TComponent; dynamic;
    function GetOwner: TPersistent; override;
    procedure Loaded; virtual;
    procedure Notification(AComponent: TComponent; Operation: TOperation); virtual;
    procedure GetDeltaStreams(Proc: TGetStreamProc); dynamic;
    procedure PaletteCreated; dynamic;
    procedure ReadState(Reader: TReader); virtual;
    function CanObserve(const ID: Integer): Boolean; virtual;
    procedure ObserverAdded(const ID: Integer; const Observer: IObserver); virtual;
    function GetObservers: TObservers; virtual;
    procedure SetAncestor(Value: Boolean);
    procedure SetDesigning(Value: Boolean; SetChildren: Boolean = True);
    procedure SetInline(Value: Boolean);
    procedure SetDesignInstance(Value: Boolean);
    procedure SetName(const NewName: TComponentName); virtual;
    procedure SetChildOrder(Child: TComponent; Order: Integer); dynamic;
    procedure SetParentComponent(Value: TComponent); dynamic;
    procedure Updating; dynamic;
    procedure Updated; dynamic;
    class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); virtual;
    procedure ValidateRename(AComponent: TComponent; const CurName, NewName: string); virtual;
    procedure ValidateContainer(AComponent: TComponent); dynamic;
    procedure ValidateInsert(AComponent: TComponent); dynamic;
    procedure WriteState(Writer: TWriter); virtual;
    procedure RemoveFreeNotifications;
    { IInterface }
    function QueryInterface(const IID: TGUID; out Obj): HResult; virtual; stdcall;
    function _AddRef: Integer; stdcall;
    function _Release: Integer; stdcall;
    { IDispatch }
    function GetTypeInfoCount(out Count: Integer): HResult; stdcall;
    function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; stdcall;
    function GetIDsOfNames(const IID: TGUID; Names: Pointer;
      NameCount, LocaleID: Integer; DispIDs: Pointer): HResult; stdcall;
    function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
      Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;
    property OnGetDeltaStreams: TGetDeltaStreamsEvent read FOnGetDeltaStreams write FOnGetDeltaStreams;
  public
    constructor Create(AOwner: TComponent); virtual;
    destructor Destroy; override;
    procedure BeforeDestruction; override;
    /// <summary>
    ///    Start an asynchronous procedure which will be execute in the context of the main thread or in the case of
    ///    a VCL TControl descendant, in the context of the thread on which the closest window handle was created
    ///    (following the parent chain). This will most likely still be on the main thread.
    /// </summary>
    function BeginInvoke(const AProc: TProc; const AContext: TObject = nil): IAsyncResult; overload;
    function BeginInvoke(const AProc: TASyncProcedureEvent; const AContext: TObject = nil): IAsyncResult; overload;
    function BeginInvoke<TResult>(const AFunc: TFunc<TResult>; const AContext: TObject = nil): IAsyncResult; overload;
    function BeginInvoke(const AProc: TAsyncConstArrayProc; const Params: array of const; const AContext: TObject = nil): IAsyncResult; overload;
    function BeginInvoke<TResult>(const AFunc: TAsyncConstArrayFunc<TResult>; const Params: array of const; const AContext: TObject = nil): IAsyncResult; overload;
    function BeginInvoke(const AProc: TAsyncConstArrayProcedureEvent; const Params: array of const; const AContext: TObject = nil): IAsyncResult; overload;
    function BeginInvoke(const AFunc: TAsyncConstArrayFunctionEvent; const Params: array of const; const AContext: TObject = nil): IAsyncResult; overload;
    function BeginInvoke(const AFunc: TAsyncFunctionEvent; const AContext: TObject = nil): IAsyncResult; overload;
    /// <summary>
    ///    Block the caller until the given IAsyncResult completes. This function will return immediately if the
    ///    IAsyncResult has already finished. This function will also raise any exception that may have happened while
    ///    the asynchronous procedure executed.
    /// </summary>
    procedure EndInvoke(const ASyncResult: IAsyncResult); overload;
    /// <summary>
    ///    Block the caller until the given IAsyncResult completes. Returns the result from the asynchronously executed
    ///    function. This function will return immediately if the IAsyncResult has already finished. This function will
    ///    also raise any exception that may have happened while the asynchronous procedure executed.
    /// </summary>
    function EndInvoke<TResult>(const AsyncResult: IAsyncResult): TResult; overload;
    /// <summary>
    ///    Block the caller until the given IAsyncResult completes. Returns the result from the asynchronously executed
    ///    function. This function will return immediately if the IAsyncResult has already finished. This function will
    ///    also raise any exception that may have happened while the asynchronous procedure executed.
    /// </summary>
    function EndFunctionInvoke(const AsyncResult: IAsyncResult): TObject;
    procedure DestroyComponents;
    procedure Destroying;
    function ExecuteAction(Action: TBasicAction): Boolean; dynamic;
    function FindComponent(const AName: string): TComponent;
    procedure FreeNotification(AComponent: TComponent);
    procedure RemoveFreeNotification(AComponent: TComponent);
    procedure FreeOnRelease;
    function GetEnumerator: TComponentEnumerator;
    function GetParentComponent: TComponent; dynamic;
    function GetNamePath: string; override;
    function HasParent: Boolean; dynamic;
    procedure InsertComponent(const AComponent: TComponent);
    procedure RemoveComponent(const AComponent: TComponent);
    procedure SetSubComponent(IsSubComponent: Boolean);
    function SafeCallException(ExceptObject: TObject; ExceptAddr: Pointer): HResult; override;
    function UpdateAction(Action: TBasicAction): Boolean; virtual;
    function IsImplementorOf(const I: IInterface): Boolean;
    function ReferenceInterface(const I: IInterface; Operation: TOperation): Boolean;
    property ComObject: IUnknown read GetComObject;
    property Components[Index: Integer]: TComponent read GetComponent;
    property ComponentCount: Integer read GetComponentCount;
    property ComponentIndex: Integer read GetComponentIndex write SetComponentIndex;
    property ComponentState: TComponentState read FComponentState;
    property ComponentStyle: TComponentStyle read FComponentStyle;
    property DesignInfo: TDesignInfo read FDesignInfo write FDesignInfo;
    property Owner: TComponent read FOwner;
    property VCLComObject: Pointer read FVCLComObject write FVCLComObject;
    property Observers: TObservers read GetObservers;
  published
    property Name: TComponentName read FName write SetName stored False;
    property Tag: NativeInt read FTag write FTag default 0;
  end;

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

Delphi 深入浅出VCL(4)

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
4个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
3年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Stella981 Stella981
3年前
Nginx反向代理upstream模块介绍
!(https://oscimg.oschina.net/oscnet/1e67c46e359a4d6c8f36b590a372961f.gif)!(https://oscimg.oschina.net/oscnet/819eda5e7de54c23b54b04cfc00d3206.jpg)1.Nginx反
Wesley13 Wesley13
3年前
ES6 新增的数组的方法
给定一个数组letlist\//wu:武力zhi:智力{id:1,name:'张飞',wu:97,zhi:10},{id:2,name:'诸葛亮',wu:55,zhi:99},{id:3,name:'赵云',wu:97,zhi:66},{id:4,na
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
10个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这