Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1A.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- //#include <Vcl.ExtCtrls.hpp>
- //#include <Vcl.ComCtrls.hpp>
- #include <Vcl.Dialogs.hpp>
- #include <map>
- // *pragma push explicit rcti
- #pragma explicit_rtti methods (__published, public) properties (__published, public)
- class TTestClass : public TObject {
- String FName;
- public :
- __property
- String Name = { read = FName };
- void DoGetRequest () { ShowMessage( __FUNC__ ); }
- void DoPostRequest () { ShowMessage( __FUNC__ ); }
- };
- typedef void (TTestClass::* TResourceFunc)();
- typedef std::map <String, TResourceFunc> TResourceFuncsList;
- void f( TTestClass* tc, TResourceFunc rf ) { (tc->*rf)(); }
- TForm1* Form1;
- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { }
- void __fastcall TForm1::Button1Click(TObject *Sender) {
- TTestClass* tc = new TTestClass();
- //f( tc, &TTestClass::DoGetRequest );
- //f( tc, &TTestClass::DoPostRequest );
- TResourceFuncsList rfl { {"Get Request", &TTestClass::DoGetRequest},
- {"Post Request", &TTestClass::DoPostRequest}
- };
- f( tc, rfl["Get Request" ] );
- f( tc, rfl["Post Request"] );
- }
- // --- --- --- --- ---
- /*
- #ifndef Unit1AH
- #define Unit1AH
- //---------------------------------------------------------------------------
- #include <System.Classes.hpp>
- #include <Vcl.Controls.hpp>
- #include <Vcl.StdCtrls.hpp>
- #include <Vcl.Forms.hpp>
- class TForm1 : public TForm
- {
- __published: // IDE-managed Components
- TButton* Button1;
- void __fastcall Button1Click (TObject* Sender);
- public: // User declarations
- __fastcall TForm1 (TComponent* Owner);
- };
- extern PACKAGE TForm1* Form1;
- #endif
- */
Add Comment
Please, Sign In to add comment