Well, you already have the answer… Your class MyMainFrame doesn’t inherit from TObject…
See your modified (and working) code below:
[code]// barebones.C
#include <TGClient.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TRandom.h>
#include <TGButton.h>
#include <TGFrame.h>
#include <TRootEmbeddedCanvas.h>
#include <RQ_OBJECT.h>
#include <TTimer.h>
class MyMainFrame : public TGMainFrame {
private:
TRootEmbeddedCanvas *fEcanvas;
TTimer *fTimer;
//char *s;
public:
MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h);
virtual ~MyMainFrame();
void DoDraw();
void EnableTimer();
void DisableTimer();
};
//this function really just initializes things
MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) :
TGMainFrame(p, w, h)
{
// Create a horizontal frame widget with buttons
TGHorizontalFrame *hframe = new TGHorizontalFrame(this,200,200);
TGTextButton *draw = new TGTextButton(hframe,"&Draw");
draw->Connect(“Clicked()”,“MyMainFrame”,this,“EnableTimer()”);
hframe->AddFrame(draw, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
TGTextButton *exit = new TGTextButton(hframe,"&Exit",“gApplication->Terminate(0)”);
hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
TGTextButton *start = new TGTextButton(hframe,"&Stop Monitor");
hframe->AddFrame(start, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
start->Connect(“Clicked()”,“MyMainFrame”,this,“DisableTimer()”);
AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));
SetWindowName(“Online Monitor”);
MapSubwindows();
Resize(GetDefaultSize());
MapWindow();
}
void MyMainFrame::DoDraw()
{
static Int_t count = 0;
cout << ++count << endl;
}
void MyMainFrame::EnableTimer()
{
fTimer = new TTimer(this, 1000);
fTimer->Connect(“Timeout()”, “MyMainFrame”, this, “DoDraw()”);
fTimer->Reset();
// Enable timer.
fTimer->TurnOn();
}
void MyMainFrame::DisableTimer()
{
cout << fTimer << endl;
fTimer->TurnOff();
}
MyMainFrame::~MyMainFrame()
{
Cleanup();
}
void barebones()
{
new MyMainFrame(gClient->GetRoot(),200,200);
}
[/code]
Cheers,
Bertrand.