TApplication::EnumAllWindowsOnActivateHint
直到 C++Builder 2009 才作为真正的 C++ 可访问属性引入。在 C++Builder 2007 中,它被实现为Class Helper的属性:
TApplicationHelper = class helper for TApplication
private
procedure SetEnumAllWindowsOnActivateHint(Flag: Boolean);
function GetEnumAllWindowsOnActivateHint: Boolean;
...
public
property EnumAllWindowsOnActivateHint: Boolean read GetEnumAllWindowsOnActivateHint write SetEnumAllWindowsOnActivateHint;
...
end;
Class Helpers是 Delphi 特有的功能,在 C++ 中无法访问。因此,您将不得不使用解决方法。创建一个单独的 .pas 文件,该文件公开 C 样式函数以访问该 EnumAllWindowsOnActivateHint
属性,然后将该 .pas 文件添加到您的 C++ 项目中:
AppHelperAccess.pas:
unit AppHelperAccess;
interface
function Application_GetEnumAllWindowsOnActivateHint: Boolean;
procedure Application_SetEnumAllWindowsOnActivateHint(Flag: Boolean);
implementation
uses
Forms;
function Application_GetEnumAllWindowsOnActivateHint: Boolean;
begin
Result := Application.EnumAllWindowsOnActivateHint;
end;
procedure Application_SetEnumAllWindowsOnActivateHint(Flag: Boolean);
begin
Application.EnumAllWindowsOnActivateHint := Flag;
end;
end.
当它被编译时,将生成一个 C++ .hpp 头文件,然后您的 C++ 代码可以使用它来调用函数。例如
#include "AppHelperAccess.hpp"
void EnableEnumAllWindowsOnActivateHint()
{
Application_SetEnumAllWindowsOnActivateHint(true);
}
void DisableEnumAllWindowsOnActivateHint()
{
Application_SetEnumAllWindowsOnActivateHint(false);
}
void ToggleEnumAllWindowsOnActivateHint()
{
bool flag = Application_GetEnumAllWindowsOnActivateHint();
Application_SetEnumAllWindowsOnActivateHint(!flag);
}