home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / cnr / dynobj / dynobj.cpp next >
Encoding:
C/C++ Source or Header  |  1996-10-29  |  1.4 KB  |  59 lines

  1. //************************************************************
  2. // Container Control - Dynamic Creation Of Objects
  3. //
  4. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  5. // Copyright (c) 1997 John Wiley & Sons, Inc. 
  6. // All Rights Reserved.
  7. //************************************************************
  8.  
  9. #include <iapp.hpp>
  10. #include <iframe.hpp>
  11. #include <icnrctl.hpp>
  12. #include <icnrcol.hpp>
  13. #include "table.hpp"
  14.  
  15. void main( )
  16. {
  17.  
  18. IFrameWindow cnrFrame("Dynamic Creation of Objects");
  19.  
  20. IContainerControl cnr(0x101,
  21.                       &cnrFrame,
  22.                       &cnrFrame);
  23.  
  24. // Size the frame & put container in client area
  25. cnrFrame
  26.   .setClient(&cnr)
  27.   .sizeTo(ISize(450,200));
  28.  
  29.  
  30. // Create a TableObject with 3 fields.
  31. TableObject::setFieldCount(3);
  32. TableObject* pobject = new TableObject;
  33. pobject->setFieldText("John Doe", 0);
  34. pobject->setFieldText("Anywhere USA", 1);
  35. pobject->setFieldText("Hacker", 2);
  36. pobject->enableDataUpdate();
  37. cnr.addObject(pobject);
  38.  
  39. // Setup the text for the column headings.
  40. TableObject::setHeadingText("Name", 0);
  41. TableObject::setHeadingText("Address", 1);
  42. TableObject::setHeadingText("Occupation", 2);
  43.  
  44. // Create and add the columns to the container.
  45. pobject->createAllColumnsFor(cnr);
  46.  
  47. // Show the details view
  48. cnr.showDetailsView();
  49.  
  50. // Set the focus and show the window
  51. cnrFrame
  52.  .setFocus()
  53.  .show();
  54.  
  55. IApplication::current().run();
  56. }
  57.  
  58.  
  59.