gpt4 book ai didi

c++ - Firemonkey:如何使用 TScreen.Forms 遍历应用程序中的所有表单

转载 作者:行者123 更新时间:2023-11-28 02:19:33 25 4
gpt4 key购买 nike

我正在尝试遍历我在应用程序中打开的表单。我找到了 FMX.Forms.TScreen.Forms 的文档,看起来它可以用来实现我的目标。但是,我对应该如何使用它感到困惑。

起初我在表单的 CPP 文件中的一个函数中尝试了这个:

ShowMessage( Forms::TScreen::FormCount );

这产生了错误'Member TScreen::FormCount cannot be used without an object'

我认为这意味着我需要尝试从我的表单或全局 Application 变量访问此属性。我都试过了

this->Forms...
Application->Forms...

this->TScreen...
Application->TScreen...

但是,FormsTScreen 都不存在于这些对象中。

如何访问 Forms.TScreen.Forms

最佳答案

这个错误给了你一个线索:

Member TScreen::FormCount cannot be used without an object

TScreen 是一个类,不是一个对象。 FormCount 不是该类的静态成员,因此您需要一个 TScreen 类的对象实例。并且为您提供了这样一个对象 - 全局 Screen 对象:

ShowMessage( Screen->FormCount );

这是在文档中说明的:

FMX.Forms.TScreen

There is a global variable, Screen, of type TScreen, which is instantiated for use by any application with a GUI. Use Screen to obtain information about the current state of the screen in an application.

FMX.Forms.Screen

extern DELPHI_PACKAGE TScreen* Screen;

关于c++ - Firemonkey:如何使用 TScreen.Forms 遍历应用程序中的所有表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33025657/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com