Firemonkey - 消息处理 [英] Firemonkey - Message Handling

查看:141
本文介绍了Firemonkey - 消息处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试开发基于Firemonkey的项目。我正在使用Firemonkey作为UI功能,因为该项目由许多较小的应用程序组成,每个都具有3D方面。我目前只使用FMX框架开发/部署到Windows,但可能会在稍后的时候跨平台。

I'm currently trying to develop a project based upon Firemonkey. I'm using Firemonkey for it's UI features as the project consists of many smaller applications, each with a 3D aspect to it. I'm currently only developing/deploying to Windows with the FMX framework, but may go cross-platform at a later date.

我遇到了大多数问题,通过在后台构建VCL Windows应用程序来执行一个非常具体的操作,然后构建一个FMX前端。但是,这只适用于您只想执行应用程序来执行其设计的操作,因此可以使用参数执行应用程序。在其中一个应用程序中,我已经需要使用消息(或类似的东西)。例如,在我的FMX应用程序中,如果我点击button1,我希望它向后台的VCL应用程序发送一条消息以执行action1,而不是使用参数执行。

I've gotten around most issues I've come across by building a VCL Windows application in the background to perform a very specific action, and then building an FMX frontend. However, this is only suitable when you only want to execute the application to perform that action it's designed to do, and thus can execute the application with parameters. In one of the applications, i've come upon the need to use messages (or something similar). For example, in my FMX application, if i click "button1", i want it to send a message to the background VCL application to perform "action1", rather than execute it with parameters.

一个很好的例子可能是在后台应用程序中使用VCL TMediaPlayer ,前端FMX应用程序用于显示信息并提供播放,暂停等的控制。它基本上成为具有VCL能力的FMX UI。

A good example could be using the VCL TMediaPlayer in the background application, with the front-end FMX application being used to display the information and provide control of play, pause, etc. Such that it essentially becomes an FMX UI with VCL ability.

我迄今为止无法找到关于消息(例如在VCL中)的任何他们将通过SendMessage或PostMessage或类似的操作)使用Firemonkey来处理,通过本地帮助文件或通过广泛的Google搜索进行处理。我所有的一切都与电子邮件有关(大概是因为我的大部分搜索字词都是Message)。

I've so far been unable to find anything on how messages (e.g. in VCL, they'd be done with "SendMessage" or "PostMessage" or something similar) are handled with Firemonkey, either through the local help file, or through extensive Googling. Everything i've turned up has been related to email (presumably because of the word "Message" in most of my search terms).

可以任何人都指出正确的方向,如何使用Firemonkey / FMX处理邮件?

Regards,
Scott Pritchard

Regards, Scott Pritchard

推荐答案

我的理解是,Firemonkey不是基于传统的窗口,所以向Firemonkey控件发送窗口消息通常不是一个选项。虽然一些控件确实使用窗口(最不清楚的是, TCommonCustomForm ),所以你可以使用 FmxHandleToHWND() FMX.Platform.Win 单元从 TFmxHandle HWND c>需要时我不知道如何在FMX控件中接收和自定义处理窗口消息,如果这是可能的。

My understanding is that Firemonkey is not based on traditional windows, so sending window messages to Firemonkey controls is not usually an option. Although some controls do use windows (most notibly, TCommonCustomForm), so you can use the FmxHandleToHWND() function in the FMX.Platform.Win unit to extract an HWND from a TFmxHandle when needed. I have no clue how to receive and custom process window messages in FMX controls, if that is even possible.

Windows下的Firemonkey可以访问Win32 API,所以应该不要阻止您将窗口消息发送到其他窗口控件,如VCL UI。在您的中使用 Winapi.Windows 单元使用子句访问Win32 API函数,就像在VCL应用程序中一样

Firemonkey under Windows has access to the Win32 API, so there should be nothing stopping you from sending window messages to other windowed controls, such as your VCL UI. Include the Winapi.Windows unit in your uses clause to access Win32 API functions, just like you would in a VCL application.

更新:因为FireMonkey不会公开对发送到窗体窗口的邮件的访问,您必须按顺序手动子窗口在FireMonkey看到它们之前接收消息。您可以重写Form的 CreateHandle()方法,首先调用继承的方法创建窗口,然后使用 FmxHandleToHWND()以获取可以子类化的 HWND 。请确保覆盖 DestroyHandle()方法以删除子类,然后调用继承以释放 HWND

UPDATE: because FireMonkey does not expose access to messages that are sent to a Form's window, you have to manually subclass the window in order to receive messages before FireMonkey sees them. You can override the Form's CreateHandle() method, call the inherited method first to create the window, then use FmxHandleToHWND() to get the HWND that you can subclass. Be sure to also override the DestroyHandle() method to remove the subclass before then calling inherited to release the HWND.

这篇关于Firemonkey - 消息处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆