[ROOT] problem with TGTransientFrame under windows

From: suaide@if.usp.br
Date: Tue Jun 15 2004 - 15:27:02 MEST


Hello all

I am using root 4.00/06 compiled with VC++7 under windows
XP and I am trying to implement a simple dialog box class that
inherits from TGTransientFrame. It works great under linux.
Under windows it compiles fine (no warnings in the code)
with VC++ 6 but when I create an object from that class the
root section freezes and I have to kill the process. The frame
opens but the buttons, labels and text entries do not show
and everything freezes.

Any help????

The code is bellow

Regars

Alex Suaide

TDialog.h -------------------------------------------------------

#ifndef TDialog_HH
#define TDialog_HH
#include "TGClient.h"
#include "TApplication.h"
#include "TGLabel.h"
#include "TGMsgBox.h"
#include "TString.h"
#include "TGTextBuffer.h"
#include "TGTextEntry.h"
#include "TGButton.h"

class TDialog : public TGTransientFrame
{
  private:
    TString          *mLabel;
    TString          *mValue;
    TGLabel          *mDgLbl[100];
    TGTextEntry      *mTE[100];
    TGButton         *mOKb;
    TGButton         *mCancelb;
    int              mN;
    int*             mStat;
  public:
                     TDialog(char*,int, TString*,TString*,int*,int=600,
int=400);
    virtual          ~TDialog();
    bool             ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);

  ClassDef(TDialog,1)
};
#endif

TDialog.cxx -------------------------------------------------------

#include "TDialog.h"

ClassImp(TDialog)
TDialog::TDialog(char* title,int N, TString *label, TString* value, int*
stat, int w, int h)
:TGTransientFrame(gClient->GetRoot(),gClient->GetRoot(),w,h)
{
  int i;
  mN = N;
  mLabel = label;
  mValue = value;
  mStat = stat;
  for(i=0;i<mN;i++)
  {
    mDgLbl[i] = new TGLabel(this, (char*)mLabel[i].Data()) ;
    mTE[i] = new TGTextEntry(this, (char*)mValue[i].Data());
    AddFrame(mDgLbl[i],new TGLayoutHints(kLHintsExpandX));
    AddFrame(mTE[i],new TGLayoutHints(kLHintsExpandX));
  }
  mOKb = new TGTextButton(this, "Ok", 21);
  mCancelb = new TGTextButton(this, "Cancel", 22);
  AddFrame(mOKb,     new TGLayoutHints(kLHintsExpandX));
  AddFrame(mCancelb, new TGLayoutHints(kLHintsExpandX));
  SetWindowName(title);
  MapSubwindows();
  Resize(GetDefaultSize());
  MapWindow();
  gClient->WaitFor(this);
}
TDialog::~TDialog()
{
  int i;
  for(i = 0;i<mN;i++)
  {
    delete mDgLbl[i];
    delete mTE[i];
  }
  delete mOKb;
  delete mCancelb;
}
bool TDialog::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
{
  int i;
  switch (GET_MSG(msg))
  {
    case kC_COMMAND:
      switch (GET_SUBMSG(msg))
      {
        case kCM_BUTTON:
          switch (parm1)
          {
            case 21:
              for(i=0;i<mN;i++)
                if(mTE[i]->GetBuffer()) mValue[i] = mTE[i]->GetText();
                else mValue[i] = "";
            *mStat = 1;
              delete this;
              break;
            case 22:
            *mStat = 0;
              delete this;
              break;
          }
     }
  }
  return true;
}




----------------------------------------
Dr. Alexandre Suaide
http://www.dfn.if.usp.br/~suaide/
55-11-3091-7072
Departamento de Física Nuclear
Universidade de São Paulo, Brasil



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET