DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: a12315
今日帖子: 49
在线用户: 10
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2019/5/16 5:41:19
标题:
Did you know is possible use VCL and FMX (FireMonkey) togheter in your app? 浏览:1896
加入我的收藏
楼主: hi Friends,

Did you know is possible use VCL and FMX (FireMonkey) togheter in your app?

Here my test about use of "VCL" and "FMX" objects togheter, to create one app to MS Windows!

Many want to use DLLs written in C / C ++ or another language along with their project in RAD Studio (Delphi or CBuilder), but they forget or do not know that a BPL is actually a binary library, such as a DLL, with due exceptions and differences in your call.

However, since a BPL is actually a binary Delphi / CBuilder code container, then this means you can create your own repository of objects (classes) and codes to use in your projects, in order to re-use their codes. (Remember one of the pillars of object-oriented language - Inheritance)

To use one framework within the other, in the case it may be: VCL within FMX, or FMX within VCL - you have to take a few basic steps.

You must create the objects that will be used by the other framework with a package (BPL / DCP), as RAD Studio does.
In your application project, VCL or FMX, you must inform that you will use a custom "RUNTIME PACKAGE", which is your newly created package.
Add the DCP file - not BPL file ok!
IT's NOT NECESSARY INSTALL THE PACKAGE IN YOUR IDE, JUST HAVE IT TO USE!
By default, RAD Studio saves the BPL and DCP files in your "Documents Public \ Embarcadero \ .... DCP and BPL sub-folders" - if you want, you can "copy it" for you project folder or any other place!
 Just DONT FORGET where is it, ok!
After that, you simply inform in your application project, in the "USES" clause, which unit you intend to use, and which is inside your "package" that you created before.
Then you can use the objects and classes as you normally do when using the RAD Studio default packages.

My project VCL that will use my TForm FMX (FireMonkey)
----------

unit uVCLFormMain;

interface

uses
  Winapi.Windows,
  Winapi.Messages,
  System.SysUtils,
  System.Variants,
  System.Classes,
  Vcl.Graphics,
  Vcl.Controls,
  Vcl.Forms,
  Vcl.Dialogs,
  Vcl.StdCtrls,
  Vcl.Menus,
  //
  uFMXForm_inVCLproject  // in my package with my objects FMX
  //
    ;

type
  TVCLFormMain = class(TForm)
    Label1: TLabel;
    MainMenu1: TMainMenu;
    Files1: TMenuItem;
    About1: TMenuItem;
    CallFMXform1: TMenuItem;
    N1: TMenuItem;
    Exit1: TMenuItem;
    procedure CallFMXform1Click(Sender: TObject);
    procedure Exit1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  VCLFormMain: TVCLFormMain;

implementation

{$R *.dfm}

procedure TVCLFormMain.CallFMXform1Click(Sender: TObject);
var
  lFMXForm_inVCLprj: TfrmFMXForm_inVCLproject;
begin
  lFMXForm_inVCLprj := TfrmFMXForm_inVCLproject.Create(nil);
  try
    lFMXForm_inVCLprj.ShowModal;
  finally
    Self.SetFocus;
    //
    lFMXForm_inVCLprj.DisposeOf;
    lFMXForm_inVCLprj := nil;
  end;
end;

procedure TVCLFormMain.Exit1Click(Sender: TObject);
begin
  Close;
end;

end.


my TForm FireMonkey (FMX) used in my VCL project
----------

unit uFMXForm_inVCLproject;

interface

uses
  System.SysUtils,
  System.Types,
  System.UITypes,
  System.Classes,
  System.Variants,
  FMX.Types,
  FMX.Controls,
  FMX.Forms,
  FMX.Graphics,
  FMX.Dialogs,
  FMX.Layouts,
  FMX.StdCtrls,
  FMX.Controls.Presentation;

type
  TfrmFMXForm_inVCLproject = class(TForm)
    AniIndicator1: TAniIndicator;
    Layout1: TLayout;
    Label1: TLabel;
    StyleBook1: TStyleBook;
    ToolBar1: TToolBar;
    sbtnClickMe: TSpeedButton;
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure sbtnClickMeClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmFMXForm_inVCLproject: TfrmFMXForm_inVCLproject;

implementation

{$R *.fmx}

procedure TfrmFMXForm_inVCLproject.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  AniIndicator1.Enabled := False;
end;

procedure TfrmFMXForm_inVCLproject.FormCreate(Sender: TObject);
begin
  Position := TFormPosition.ScreenCenter;
end;

procedure TfrmFMXForm_inVCLproject.FormShow(Sender: TObject);
begin
  AniIndicator1.Enabled := False;
  AniIndicator1.Enabled := True;
end;

procedure TfrmFMXForm_inVCLproject.sbtnClickMeClick(Sender: TObject);
begin
  ShowMessage('Hello FMX project');
end;

end.


my project FireMonkey (FMX) that will use my TForm VCL
----------

unit uFMXFormMain;

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,
  FMX.Layouts,
  //
  uVCLForm_inFMXproject  // in my package with my objects VCL
  //
    ;

type
  TFMXFormMain = class(TForm)
    Layout1: TLayout;
    ToolBar1: TToolBar;
    sbtnCallVCLForm: TSpeedButton;
    sbtnCloseApp: TSpeedButton;
    Label1: TLabel;
    StyleBook1: TStyleBook;
    procedure FormCreate(Sender: TObject);
    procedure sbtnCallVCLFormClick(Sender: TObject);
    procedure sbtnCloseAppClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FMXFormMain: TFMXFormMain;

implementation

{$R *.fmx}

procedure TFMXFormMain.FormCreate(Sender: TObject);
begin
  Position := TFormPosition.ScreenCenter;
end;

procedure TFMXFormMain.sbtnCallVCLFormClick(Sender: TObject);
var
  lVCLForm_inFMXprj: TfrmVCLForm_inFMXproject; // my TForm VCL
begin
  lVCLForm_inFMXprj := TfrmVCLForm_inFMXproject.Create(nil);
  try
    lVCLForm_inFMXprj.ShowModal;
  finally
    Self.Active := True;
    //
    lVCLForm_inFMXprj.DisposeOf;
    lVCLForm_inFMXprj := nil;
  end;
end;

procedure TFMXFormMain.sbtnCloseAppClick(Sender: TObject);
begin
  Close;
end;

end.
----------

my TForm VCL used in my project FireMonkey (FMX)
----------

unit uVCLForm_inFMXproject;

interface

uses
  Winapi.Windows,
  Winapi.Messages,
  System.SysUtils,
  System.Variants,
  System.Classes,
  Vcl.Graphics,
  Vcl.Controls,
  Vcl.Forms,
  Vcl.Dialogs,
  Vcl.StdCtrls,
  Vcl.ExtCtrls,
  Vcl.ComCtrls,
  Vcl.ToolWin,
  Vcl.Menus,
  System.ImageList,
  Vcl.ImgList,
  System.Actions,
  Vcl.ActnList,
  Vcl.StdActns,
  Vcl.Themes;

type
  TfrmVCLForm_inFMXproject = class(TForm)
    Label1: TLabel;
    Panel1: TPanel;
    Animate1: TAnimate;
    ToolBar1: TToolBar;
    Button1: TButton;
    Button2: TButton;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ComboBox1: TComboBox;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmVCLForm_inFMXproject: TfrmVCLForm_inFMXproject;

implementation

{$R *.dfm}

const
  lPathStyles = 'C:\Users\Public\Documents\Embarcadero\Studio\20.0\Styles';

procedure TfrmVCLForm_inFMXproject.Button1Click(Sender: TObject);
begin
  ShowMessage('Hello VCL project');
end;

procedure TfrmVCLForm_inFMXproject.Button2Click(Sender: TObject);
begin
  Close;
end;

procedure TfrmVCLForm_inFMXproject.ComboBox1Change(Sender: TObject);
begin
  if (ComboBox1.Items.Count > 0) then
    TStyleManager.SetStyle(ComboBox1.Text);
end;

procedure TfrmVCLForm_inFMXproject.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Animate1.Active := False;
end;

procedure TfrmVCLForm_inFMXproject.FormCreate(Sender: TObject);
var
  lStyleName: string;
begin
  Position := TPosition.poScreenCenter;
  //
  for lStyleName in TStyleManager.StyleNames do
    ComboBox1.Items.Add(lStyleName);
  //
  if (ComboBox1.Items.Count > 0) then
    ComboBox1.ItemIndex := 0;
end;

procedure TfrmVCLForm_inFMXproject.FormShow(Sender: TObject);
begin
  Animate1.Active := False;
  Animate1.Active := True;
end;

initialization

finalization

end.


my code source complete: (compressed using 7-Zip last)  - 14 servers 

https://www.mirrored.to/files/KOA57DNM/VCL_and_FMX_togheter.zip_links


hug
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2019/5/16 5:48:43
1楼: Screens

按此在新窗口浏览图片
按此在新窗口浏览图片
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 draculamx (draculamx) ▲▲▲▲△ -
普通会员
2019/5/16 8:10:31
2楼: C++ builder 也能把VCL和FMX一起使用吗,用来开发windows的桌面程序?
----------------------------------------------
C++ builder 用户前来摸鱼。。。
作者:
男 hjandy (andy) ★☆☆☆☆ -
普通会员
2019/5/16 20:13:50
3楼: 请问有下载了能附件共享吗
----------------------------------------------
andy
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2019/5/16 22:43:49
4楼: if you can add the bpl in your project, yes!

https://www8.zippyshare.com/v/kbmj60kv/file.html
https://clicknupload.org/v7c48lmmsd3t
http://www.solidfiles.com/d/An754dAxPN6jX
https://openload.co/f/dgnyct9TVKc/VCL_and_FMX_togheter.zip
https://bayfiles.com/xfB8J4rcnc/VCL_and_FMX_togheter_zip
https://anonfile.com/v6B1J5r9na/VCL_and_FMX_togheter_zip
https://ddl.to/tgc8zeuo5wur
https://tusfiles.com/h23gl726ho7g
https://1fichier.com/?5fll4t9l2ppj60r2or2a
https://sendit.cloud/undef
https://douploads.com/a1pt0h6vhv9a
https://www.file-up.org/f5q06tilb05p
https://nofile.io/f/xvQgZZaXn9d/VCL_and_FMX_togheter.zip
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 lsuper (lsuper) ★☆☆☆☆ -
盒子活跃会员
2019/5/17 8:00:00
5楼: 感谢楼主分享;原理上和这个的区别?

https://parnassus.co/tfiremonkeycontainer-a-vcl-control-for-mixing-vcl-and-fmx/
----------------------------------------------
-
作者:
男 zyp1984 (小李他妈的飞刀) ★☆☆☆☆ -
普通会员
2019/5/17 9:14:21
6楼: 这样做的意义是什么呀。。
----------------------------------------------
山外青山楼外楼,能人背后有能人弄..
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2019/5/17 22:33:02
7楼: for example:

You have your app VCL and would like show 3D effects/picture etc... without use 3rd party components.
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行70.3125毫秒 RSS