• Delphi XE2 之 FireMonkey 入门(45Finally)



    很喜欢 FMX 的一些新控件, 如: TExpander、TArcDial、TComboTrackBar、TPathLabel 等等, 没时间继续学习了.

    对 FMX 的整体感觉: 还不成熟, 但肯定有前景; 它的构架师有远见、了不起, 很难估计他开启的是多大一扇门!

    本将继续学习:
    1、TCanvas、TBrush、TApplication;
    2、FMX 中的 GDI+、D2D、DirectX;
    3、FMX 3D;
    4、XE2 中新增的其他内容(譬如新增的 TZipFile 类, 已测试过、下帖附上).

    又要忙其它事情了, 但愿能尽早有时间和心情回来继续学习.

    正在学习但没有学完的东西是关于拖放的; 现在的 FMX 窗体可以直接响应拖放了, 譬如: 拖拽文本文件到窗体让 TMemo 打开.

    unit Unit1;
    
    interface
    
    uses
      System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
      FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Layouts, FMX.Memo;
    
    type
      TForm1 = class(TForm)
        Memo1: TMemo; //先在空白窗体上放 Memo1
      private
      public
        { 覆盖这个两个方法 }
        procedure DragOver(const Data: TDragObject; const Point: TPointF; var Accept: Boolean); override;
        procedure DragDrop(const Data: TDragObject; const Point: TPointF); override;
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.fmx}
    
    { TForm1 }
    
    procedure TForm1.DragOver(const Data: TDragObject; const Point: TPointF; var Accept: Boolean);
    begin
      inherited;
      { 如果拖拽的是文件, 且是 *.txt 文件, 则让 Accept := True 以让后面的 DragDrop 事件响应 }
      Accept := (Length(Data.Files) > 0) and (CompareText(ExtractFileExt(Data.Files[0]), '.txt') = 0);
    end;
    
    procedure TForm1.DragDrop(const Data: TDragObject; const Point: TPointF);
    begin
      inherited;
      Memo1.Lines.LoadFromFile(Data.Files[0]);
    end;
    
    end.


    来不及学习的问题: TDropTarget 应该是直接和拖放相关的, TImageControl 中也有相关拖放的代码...

    发现不大对头, 估计是源码有问题; 但愿谁学到了, 多少给我简介下.
  • 相关阅读:
    javascript面向对象程序设计之浅谈2
    Sphinx学习之sphinx的安装篇
    IT人的职业生涯规划
    perconatoolkit系列之系统类工具的使用
    perconatoolkit系列之实用类工具使用
    查询ip归属地的shell脚本
    使用mysqlsla分析Mysql数据库日志
    MYSQL管理之主从同步管理
    MYSQL数据库管理之权限管理
    perconatoolkit系列之复制类工具使用
  • 原文地址:https://www.cnblogs.com/dzdd/p/3346961.html
Copyright © 2020-2023  润新知