MessageProcess question


I started from the simple gui example which uses the MessageProcess method:
then I wanted to add to it Tabs.

The problem that I have now, is that the MessageProcess works only when with the mouse, i switch from one Tab to the other.
No message is printed out if in one of these two tabs, I select one of the two buttons.

Shall I create my own classes for each of the two Tab objects and define a MessageProcess Method for each of these two objects, or is there a much faster solution?

In advance, thanks for your valuable help.
Ps: find below the program, which compiles well.

// mymain.cxx code
#include “mymain.h”
#include <iostream.h>

MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h)
: TGMainFrame(p, w, h)

TabFrame = new TGTab(this, w, h);
fLayoutTabFrame = new TGLayoutHints(kLHintsExpandX|kLHintsCenterX,2,2,2,2);

TabFrame1= TabFrame->AddTab("-1-");
fButtonExit = new TGTextButton(TabFrame1, “&Exit”,2);
fLayoutTab1 = new TGLayoutHints(kLHintsExpandX|kLHintsCenterX,2,2,2,2);
TabFrame1->AddFrame(fButtonExit, fLayoutTab1);

TabFrame2= TabFrame->AddTab("-2-");
fChkButton = new TGCheckButton(TabFrame2, “Check Button”, 4);
fLayoutTab2 = new TGLayoutHints(kLHintsExpandX|kLHintsCenterX,2,2,2,2);
TabFrame2->AddFrame(fChkButton, fLayoutTab2);



SetWindowName(“Button Example”);
SetIconName(“Button Example”);


Bool_t MyMainFrame::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
cout << “In Process Message” << endl;
return kTRUE;

// mymain.h file
#include <TGClient.h>
#include <TGButton.h>
#include <TGTab.h>
class MyMainFrame : public TGMainFrame {

TGTab *TabFrame;
TGCompositeFrame *TabFrame1;
TGCompositeFrame *TabFrame2;

TGTextButton *fButtonExit, *fButtonVersion;
TGCheckButton *fChkButton;
TGLayoutHints *fLayoutTabFrame;
TGLayoutHints *fLayoutTab1;
TGLayoutHints *fLayoutTab2;

MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
~MyMainFrame() { } // need to delete here created widgets
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
// File: main.cxx

#include <TApplication.h>
#include <TGClient.h>
#include “mymain.h”

int main(int argc, char **argv)
TApplication theApp(“App”, &argc, argv);
MyMainFrame mainWin(gClient->GetRoot(), 800, 800);
return 0;

Hi Nabil,
to be able ProcessMessage from buttons
you need to call TGWidget::Associate method, e.g.

fButtonExit->Associate(this); // where this is MyMainFrame object

HTH. Regards. Valeriy

thanks it’s perfectly working!