コード例 #1
0
ファイル: makerez.cpp プロジェクト: idispatch/tvision
void makerez()
{
   fpstream *ofps=0;


   cout<< "Creating "<< rezFileName << endl;

   ofps = new fpstream( rezFileName, CLY_IOSOut | CLY_IOSBin );
   if( !ofps->good() )
    {
      cerr<< rezFileName <<": init failed..."<<endl;
      exit(1);
    }

   TResourceFile *myRez;
   myRez = new TResourceFile( ofps );
   if( !myRez )
   {
     cerr<< "Resource file init failed..."<<endl;
     exit(1);
   }

   TDialog *pd = new TDialog(TRect(0,0,60,15),"Example Progress Bar");
   pd->options |= ofCentered;
   pd->flags &= ~wfClose;
   TProgressBar *pbar = new TProgressBar(TRect(2,2,pd->size.x-2,3),300);
   pd->insert(new TButton(TRect(10,pd->size.y-3,pd->size.x-10,pd->size.y-1),"~C~ancel",cmCancel,bfDefault));

   if( !pbar )
   {
    cerr<< "Progress Bar init failed..."<<endl;
    exit(1);
    }

   if( !pd )
   {
    cerr<< "Dialog Box init failed..."<<endl;
    exit(1);
    }

   /*
      We need a separate TProgressBar stream because you need that object
      visible outside the dialog box in order to update it via
               TProgressBar::update(double progress);
   */
   myRez->put( pbar, "theProgressBar");

   // Here is the stream for the dialog box.
   myRez->put( pd, "theDialogBox");

   TObject::destroy( pd );
   TObject::destroy( pbar );
   TObject::destroy( myRez);
}
コード例 #2
0
ファイル: GENFORM.CPP プロジェクト: Mikelle02/GameMaker
int main(void)
{
    TSortedCollection *collection;
    int i;
    TForm *f;
    void *p;
    fpstream *s;
    TResourceFile* r;

    cout <<"Creating  " << rezFileName << "\n";

    // Construct stream and resource
    s = new fpstream (rezFileName, ios::out|ios::binary);
    r = new TResourceFile(s);

    // Form
    f = makeForm();
    r->put(f, "FormDialog");

    // Data
    collection = new TDataCollection((dataCount + 10), 5, sizeof(TDataRec),
                                     dataKeyType);
    collection->duplicates = allowDuplicates;
    for(i = 0; i < dataCount; ++i)
    {
        p = new TDataRec;
        f->setData((void *)&data[i]);      // move into object
        f->getData(p);                     // move onto heap
        collection->insert(p);             // insert in sorted order
    }
    r->put(collection, "FormData");

    // Done
    TObject::destroy(f);
    TObject::destroy((TCollection *)collection);
    TObject::destroy(r);
    return 0;
}