I know I isn't exactly related to C++, but I'm having a little trouble when a call a function named LoadAd(). I've tried to use this function into a timer in OnTimer, in events like OnFormShow and OnFormCreate(Yes, I know it cant be in that function, but I tried). However the application always gets FC (Forced close) when executing this function... Are there any solution for that?
Here is part of my code:
void __fastcall TfrmPrincipal::FormCreate(TObject *Sender)
{
// This defines the default active tab at runtime
abasPrinc->ActiveTab = abaDisp;
Auto = false;
Manual = false;
SEM_AD = false;
ad1->AdUnitID = "SECRET";
ad2->AdUnitID = "SECRET";
}
and:
void __fastcall TfrmPrincipal::FormShow(TObject *Sender)
{
ad1->LoadAd();
ad2->LoadAd();
}
Declaraion (Principal.h)
//---------------------------------------------------------------------------
#ifndef PrincipalH
#define PrincipalH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <FMX.Controls.hpp>
#include <FMX.Forms.hpp>
#include <FMX.ActnList.hpp>
#include <FMX.Gestures.hpp>
#include <FMX.StdCtrls.hpp>
#include <FMX.TabControl.hpp>
#include <FMX.Types.hpp>
#include <System.Actions.hpp>
#include <FMX.ListView.hpp>
#include <FMX.ListView.Types.hpp>
#include <FMX.MultiView.hpp>
#include <FMX.Advertising.hpp>
#include <FMX.Layouts.hpp>
#include <FMX.ListBox.hpp>
#include <FMX.Objects.hpp>
#include <FMX.Memo.hpp>
//---------------------------------------------------------------------------
class TfrmPrincipal : public TForm
{
__published: // IDE-managed Components
/* ... */
TBannerAd *ad1;
TBannerAd *ad2;
/* ... */
void __fastcall FormCreate(TObject *Sender);
void __fastcall FormKeyUp(TObject *Sender, WORD &Key, System::WideChar &KeyChar,
TShiftState Shift);
/* ... */
void __fastcall FormShow(TObject *Sender);
/* ... */
private: // User declarations
public: // User declarations
__fastcall TfrmPrincipal(TComponent* Owner);
void adaptar();
int Num(unsigned char caractere);
void RedefInicio ();
};
//---------------------------------------------------------------------------
extern PACKAGE TfrmPrincipal *frmPrincipal;
//---------------------------------------------------------------------------
#endif
Since now thanks A LOT.