Re: kCM_TAB does not work in a frame

Fons Rademakers (Fons.Rademakers@cern.ch)
Mon, 30 Nov 1998 12:58:27 +0100


Hi Wei,

it does not work in the first case because you did not implement
a ProcessMessage() method for MainFrame that will handle the kCM_TAB
event. By default widget events are send to the widgets parent frame.
In case 1 that is MainFrame, while in case 2 it is "this" which is
Monitor, which has a good ProcessMessage() method.

However, it is very simple to change the message handling frame. Just
use the Associate() method to associate a message handler to a widget.
So to get case 1 to work properly add the line:

SelectPC->Associate(this);

The TGTab appears in MainFrame, but its messages are handled by "this".

Cheers, Fons.

> Dear Rooters
>
> The attached 2 simple codes are almost the same with each other except
> that the 1st one (i.e. o1.h, o1.c) define a 'MainFrame' and add the TGTab
> object 'SelectPC' inside the 'MainFrame', e.g.
>
> MainFrame=new TGCompositeFrame(this,100,100,kHorizontalFrame);
> SelectPC = new TGTab(MainFrame, 300,300);

SelectPC->Associate(this); // add this line

> .....................
> MainFrame->AddFrame(SelectPC,PCLayout);
>
> while the 2nd one(i.e. o2.c, o2.h) do the following:
>
> SelectPC = new TGTab(this,300,300);
> .....................
> AddFrame(SelectPC,PCLayout);
>
> In the 2nd case, the keyword 'kCM_TAB' in implementation
> 'ProcessMessage' really works when click each tab with mouse,
> and give messages like "Tab unit 1 is activated".
> In the 1st case, it does not work.
> Could you tell me the reason ?

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland          Phone: +41 22 7679248
E-Mail: Fons.Rademakers@cern.ch              Fax:   +41 22 7677910