home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 2.ddi / TVDEMOS.ZIP / GENFORM.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.3 KB  |  73 lines

  1. /*------------------------------------------------------------------*/
  2. /*                                                                  */
  3. /*   Turbo Vision 1.0                                               */
  4. /*   Turbo Vision Forms Demo                                        */
  5. /*   Copyright (c) 1991 by Borland International                    */
  6. /*                                                                  */
  7. /*------------------------------------------------------------------*/
  8. /*                                                                  */
  9. /*    This program uses GENPHONE.H and GENPARTS.H to generate forms */
  10. /*  data files which are used by the TVFORMS demo program. Use      */
  11. /*  GENFORMS.MAK to create data files for TVFORMS demo.             */
  12. /*------------------------------------------------------------------*/
  13.  
  14. #define Uses_fpstream
  15. #define Uses_TResourceFile
  16. #include <tv.h>
  17. __link ( RResourceCollection )
  18.  
  19. #if defined( PHONENUM )
  20. #include "genphone.h"
  21. #elif defined( PARTS )
  22. #include "genparts.h"
  23. #else
  24. #error Specify PHONENUM or PARTS as a conditional define, compile and then run.
  25. #endif
  26.  
  27. #if !defined( __FORMS_H )
  28. #include "forms.h"
  29. #endif  // __FORMS_H
  30.  
  31. #if !defined( __STDLIB_H )
  32. #include <stdlib.h>
  33. #endif  // __STDLIB_H
  34.  
  35. int main(void)
  36. {
  37.     TSortedCollection *collection;
  38.     int i;
  39.     TForm *f;
  40.     void *p;
  41.     fpstream *s;
  42.     TResourceFile* r;
  43.  
  44.     cout <<"Creating  " << rezFileName << "\n";
  45.  
  46.     // Construct stream and resource
  47.     s = new fpstream (rezFileName, ios::out|ios::binary);
  48.     r = new TResourceFile(s);
  49.  
  50.     // Form
  51.     f = makeForm();
  52.     r->put(f, "FormDialog");
  53.  
  54.     // Data
  55.     collection = new TDataCollection((dataCount + 10), 5, sizeof(TDataRec),
  56.                           dataKeyType);
  57.     collection->duplicates = allowDuplicates;
  58.     for(i = 0; i < dataCount; ++i)
  59.         {
  60.         p = new TDataRec;
  61.         f->setData((void *)&data[i]);      // move into object
  62.         f->getData(p);                     // move onto heap
  63.         collection->insert(p);             // insert in sorted order
  64.         }
  65.     r->put(collection, "FormData");
  66.  
  67.     // Done
  68.     TObject::destroy(f);
  69.     TObject::destroy((TCollection *)collection);
  70.     TObject::destroy(r);
  71.     return 0;
  72. }
  73.