zoukankan      html  css  js  c++  java
  • Delphi中简单的回调函数

    -----------

    回调函数的说明:回调函数(callback)是什么? - 知乎  https://www.zhihu.com/question/19801131

    ----------

    -------------

    了解一下这个:Delphi 中三种回调函数形式解析 - 码农的笔记 - 博客园  https://www.cnblogs.com/dmqhjp/p/14776209.html

    有必要

    --------------

    ----------------------------------------------开发环境-D7

    ------Unit开始

    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls ;

    type
    TFCall=function(i:integer):string; //回调函数类型声明
    TForm1 = class(TForm)
    Button2: TButton;
    procedure Button2Click(Sender: TObject);
    private
    { Private declarations }
    public
    function GetStr(F:TFCall; i:integer):string;
    { Public declarations }
    end;
    var
    Form1: TForm1;

    implementation

    {$R *.dfm}
    function FCallBack01(i:integer):string; //回调函数定义
    begin
    Result:=IntToStr(i)+'100';
    end;
    procedure TForm1.Button2Click(Sender: TObject);
    begin
    ShowMessage(GetStr(FCallBack01,22));
    end;

    function TForm1.GetStr(F: TFCall; i:integer): string;
    begin
    Result:=F(i);
    end;

    end.

    ---------------unit结束

    -----------Form开始

    object Form1: TForm1
    Left = 756
    Top = 527
    Width = 263
    Height = 146
    Caption = 'Form1'
    Color = clBtnFace
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    OldCreateOrder = False
    PixelsPerInch = 96
    TextHeight = 13
    object Button2: TButton
    Left = 64
    Top = 40
    Width = 75
    Height = 25
    Caption = 'Button2'
    TabOrder = 0
    OnClick = Button2Click
    end
    end

    ---------------Form结束

    ------------------------------------------------

    另一个:Delphi中回调函数的简单例子 - 码农的笔记 - 博客园  https://www.cnblogs.com/dmqhjp/p/14772029.html

  • 相关阅读:
    编程浪子我的个人知识树
    JAVA基本数据类型
    JS导出数据为表格-csv
    table表格打印样式
    ENTER键指定事件
    legend生成表单边框效果
    js按拼音排序算法
    CommonJs规范
    iscroll在安卓高版本(6.0以上)某些机型上滑动卡顿问题的解决方法
    前端常见报错原因详解
  • 原文地址:https://www.cnblogs.com/dmqhjp/p/14900151.html
Copyright © 2011-2022 走看看