home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 April / Chip_1997-04_cd.bin / prezent / cb / data.z / FRMVIEWS.CPP < prev    next >
C/C++ Source or Header  |  1997-01-16  |  2KB  |  60 lines

  1. //----------------------------------------------------------------------------
  2. //Borland C++ Builder
  3. //Copyright (c) 1987 Borland International Inc. All Rights Reserved.
  4. //----------------------------------------------------------------------------
  5. //---------------------------------------------------------------------------
  6. #include <vcl.h>
  7. #pragma hdrstop
  8.  
  9. #include "Frmviews.h"
  10. #include "DmCSDemo.h"
  11. //---------------------------------------------------------------------------
  12. #pragma resource "*.dfm"
  13. TFrmViewDemo *FrmViewDemo;
  14.  
  15. //---------------------------------------------------------------------------
  16. __fastcall TFrmViewDemo::TFrmViewDemo(TComponent* Owner)
  17.   : TForm(Owner)
  18. {
  19. }
  20. //---------------------------------------------------------------------
  21. // Check to see if there is a format for a try..finally block.
  22. void TFrmViewDemo::ShowTable(char *ATable)
  23. {
  24.    // This is a perfect examples of where a try..finally block is needed
  25.    //  try should be done after the Screen->Cursor = crSQLWait and
  26.    //  then in the finally section, call Screen->Cursor = crDefault.
  27.    //  This would eliminate the two crDefault calls.
  28.    Screen->Cursor = crSQLWait;           // show user something is happening
  29.    try
  30.    {
  31.       VaryingTable->DisableControls();   // hide data changes from user
  32.       VaryingTable->Close();             // close the table
  33.       VaryingTable->TableName = ATable;  // update the table name
  34.       VaryingTable->Open();              // open the table
  35.       VaryingTable->EnableControls();    // show the data changes
  36.       Screen->Cursor = crDefault;        // reset the pointer
  37.    }
  38.    catch(char *E)
  39.    {
  40.       Screen->Cursor = crDefault;
  41.       ShowMessage(E);
  42.    }
  43. }
  44. //---------------------------------------------------------------------------
  45. void __fastcall TFrmViewDemo::FormShow(TObject *Sender)
  46. {
  47.    VaryingTable->Open();
  48. }
  49. //---------------------------------------------------------------------
  50. void __fastcall TFrmViewDemo::BtnShowEmployeeClick(TObject *Sender)
  51. {
  52.    ShowTable("EMPLOYEE");
  53. }
  54. //---------------------------------------------------------------------
  55. void __fastcall TFrmViewDemo::BtnShowPhoneListClick(TObject *Sender)
  56. {
  57.    ShowTable("PHONE_LIST");
  58. }
  59. //---------------------------------------------------------------------
  60.