zoukankan      html  css  js  c++  java
  • Form1调用Unit2类中函数

    Form1有一个button,当Form1.Create时触发Button的OnClick事件,OnClick事件调用Unit2单元中的函数;

    unit Unit2;  
    
    interface
      uses FMX.Dialogs, FMX.StdCtrls;
    
    type
      TBClick = class
      private
    
      public
        procedure BClick(Sender: TObject);
    
      end;
    
    implementation
    
    { BClick }
    
    procedure TBClick.BClick(Sender: TObject);
    begin
      ShowMessage('hello');
    end;
    
    end.
    
    unit Unit1;
    
    interface
    
    uses
      System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
      FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
      FMX.Controls.Presentation, FMX.StdCtrls;
    
    type
      TForm2 = class(TForm)
        Button1: TButton;
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form2: TForm2;
    
    implementation
    uses
      Unit3;
    
    {$R *.fmx}
    
    { TForm2 }
    
    procedure TForm2.FormCreate(Sender: TObject);
    var
      bclick: TBClick;
    begin
      Button1.OnClick := bclick.BClick;  
      Button1.OnClick(Sender);        // hello
    end;
    
    end.
    
  • 相关阅读:
    学习进度条
    阅读《实例化需求》10-12章有感
    学习进度条
    阅读《实例化需求》7–9章有感
    学习进度条
    软件需求与分析课堂讨论一
    课程引言课后作业1
    MVC实例应用模式
    MVC模式介绍
    二十三种设计模式
  • 原文地址:https://www.cnblogs.com/studypanp/p/4942564.html
Copyright © 2011-2022 走看看