Exposing a property in delphi to C++ from the VCL -


enumallwindowsonactivatehint property tapplication, , according help, should exposed in c++ builder - codegear 2007. not.

my difficulty need expose c++ or otherwise set true application.

so there different avenues accomplish this, , things i've tried , did wrong:

  1. exposed enumallwindowsonactivatehint in forms.pas. however, having difficulty getting change included application/vcl. i've tried i've read on recompiling vcl. nothing has worked.
  2. call delphi code can access property c++.
  3. something else?

i cannot upgrade newer version of codegear, break rtti behavior application relies on.

suggestions? solutions?

tapplication::enumallwindowsonactivatehint not introduced real c++-accessible property until c++builder 2009. in c++builder 2007, implemented property of class helper instead:

tapplicationhelper = class helper tapplication private   procedure setenumallwindowsonactivatehint(flag: boolean);   function getenumallwindowsonactivatehint: boolean;   ... public   property enumallwindowsonactivatehint: boolean read getenumallwindowsonactivatehint write setenumallwindowsonactivatehint;   ... end; 

class helpers delphi-specific feature not accessible in c++. have use workaround. create separate .pas file exposes c-style functions access enumallwindowsonactivatehint property, , add .pas file c++ project:

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. 

when gets compiled, c++ .hpp header file generated c++ code can use call functions. example

#include "apphelperaccess.hpp"  void enableenumallwindowsonactivatehint() {     application_setenumallwindowsonactivatehint(true); }  void disableenumallwindowsonactivatehint() {     application_setenumallwindowsonactivatehint(false); }  void toggleenumallwindowsonactivatehint() {     bool flag = application_getenumallwindowsonactivatehint();     application_setenumallwindowsonactivatehint(!flag); } 

Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -