如何在一个应用程序中同时拥有 VCL 和 FMX?
我有一个 VCL 应用程序和相当独立的 VCL 代码。我想包括 Fire Monkey 表单以支持 Mac OSX。
我计划大量使用 IFDEF 来确定应该使用 VCL 为 Windows 构建还是使用 FireMonkey 为 Mac OSX 构建。
不幸的是,如果应用程序是 VCL 平台,则无法从项目管理器添加 MacOS 平台。
有没有办法以某种方式破解这个?也许手动调整 .dpr 和 .dproj 文件?
I have a VCL application and pretty isolated VCL code. I would like to include Fire Monkey forms for Mac OSX support.
I plan using heavily IFDEF to determine should I build for Windows with VCL or for Mac OSX with FireMonkey.
Unfortunately there is no way to add MacOS platform from the Project Manager if the application is VCL one.
Is there a way to hack this somehow? Maybe manually tweak the .dpr and .dproj files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
反过来怎么样:
对于 1-form 项目来说,执行此操作并不难,然后添加所有当前 VCL dpr 中的现有内容。
这实际上可能会让您能够弄清楚 VCL 和 FireMonkey 的 .dpr 和 .dproj 有何不同(我尝试过一次,但短期内要做的事情太多,所以我将其搁置以供将来研究)。
注意:
将 IFDEF 放入 DPR 文件时要非常小心。 Delphi IDE 拥有 DPR 文件,并且会删除 IFDEFS,例如当您添加新表单或更改某些项目属性时。
What about doing it the other way around:
It is not that hard to do this for a 1-form project, then add all the existing stuff from your current VCL dpr.
This might actually lead you to be able to figure out how the .dpr and .dproj of VCL and FireMonkey differ (I tried once, but it was too much to do in a short term way, so I shelved it for future research).
Note:
Be very careful when putting IFDEF in your DPR files. The Delphi IDE owns DPR files, and will remove the IFDEFS, for instance when you add new forms or change some project properties.
您是否尝试过手动编辑 dproj 文件以在
标记中添加 OSX32?您可能知道这一点,但如果您不知道,请参阅MonkeyMixer 来自 Simon Stuart 的插件,可以帮助将 FMX 表单添加到您的项目中。
请注意,我无法真正测试 Mac 上的任何内容,到目前为止我仍然 100% Windows...
Have you tried manually editing the dproj file to add OSX32 in the
<Platforms>
tag?You are probably aware of it, but in case you aren't, there is this MonkeyMixer plugin from Simon Stuart that can help adding the FMX forms to your project.
Note that I cannot really test any of that's for Mac, I'm still 100% Windows so far...
将 VCL 代码与其他代码隔离是一个非常好的迹象。
n 层架构确实有意义,恕我直言,完整的 RAD 方法对于原型设计很有好处,但对于创建具有附加功能的可维护应用程序有一些严重的缺点。
使用 Delphi XE2 的标准方法是仅使用 FireMonkey 表单和 UI。因此,交叉编译将变得容易。就可维护性而言,这确实非常有意义:一旦设置了 FireMonkey 代码和表单,您只需重新编译就可以将它们部署在多个平台上。并且不要忘记,Linux 在不久的将来可能会成为目标(DXScene 已为 Linux 和 Android 做好准备)。使用表单转换器可以帮助您使用 FireMonkey 而不是 VCL 编写代码。
如果您只需要一些适用于 Mac OS X 的简单表单,并期望适用于 Windows 的更复杂的应用程序(这可能是一个想法,具体取决于营销目标),您可以创建一个纯粹的 FireMonkey“轻型”应用程序。但我不建议使用大量的条件定义。使用适当的 FireMonkey 平台创建多样化的项目。然后在 VCL 项目和 FireMonkey 项目之间共享所有非 VCL 单元。您不需要为此模式进行条件定义。
It's a very good sign to have your VCL code isolated from the other code.
n-Tier architecture does make sense, and IMHO a full RAD approach is good for prototyping, but has some severe drawbacks for creating maintainable applications, with additional features.
The standard way of using Delphi XE2 is to use only FireMonkey forms and UI. Therefore, cross-compilation will be made easy. This does perfectly make sense, in term of maintability: once your FireMonkey code and forms are set, you can deploy them on several platforms, just by a recompilation. And do not forget that Linux will possibly be a target in the close future (DXScene was Linux and Android ready). Using a form converter may help you have the code using FireMonkey instead of the VCL.
If you only need some simple forms for Mac OS X, and expect a more complex application for Windows (which could be an idea, depending on marketing targets), you can create a pure FireMonkey "light" application. But I do not recommend using a lot of conditional define. Create a diverse project, with a proper FireMonkey platform. Then share all your non-VCL units among the VCL project and the FireMonkey project. You do not need conditional define for this pattern.