home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / borland / cb / setup / cbuilder / data.z / TOOLBAR.CPP < prev    next >
C/C++ Source or Header  |  1997-02-28  |  4KB  |  118 lines

  1. //----------------------------------------------------------------------------
  2. //Borland C++Builder
  3. //Copyright (c) 1987, 1997 Borland International Inc. All Rights Reserved.
  4. //----------------------------------------------------------------------------
  5. //---------------------------------------------------------------------------
  6. #include <vcl.h>
  7. #pragma hdrstop
  8.  
  9. #include "Toolbar.h"
  10. #include "DM.h"
  11. #include "About.h"
  12. //---------------------------------------------------------------------------
  13. #pragma resource "*.dfm"
  14. TfmToolbar *fmToolbar;
  15. //---------------------------------------------------------------------------
  16. __fastcall TfmToolbar::TfmToolbar(TComponent* Owner)
  17.   : TForm(Owner)
  18. {
  19. }
  20. //---------------------------------------------------------------------------
  21. void __fastcall TfmToolbar::Close1Click(TObject *Sender)
  22. {
  23.   Application->Terminate();
  24. }
  25. //---------------------------------------------------------------------
  26. void __fastcall TfmToolbar::about1Click(TObject *Sender)
  27. {
  28.   fmAboutBox->ShowModal();
  29. }
  30. //---------------------------------------------------------------------
  31. void __fastcall TfmToolbar::Messages1Click(TObject *Sender)
  32. {
  33.   // Used to display messages on change of focus.
  34.   Messages1->Checked = !Messages1->Checked;
  35. }
  36. //---------------------------------------------------------------------
  37. void __fastcall TfmToolbar::Tile1Click(TObject *Sender)
  38. {
  39.   Tile();
  40. }
  41. //---------------------------------------------------------------------
  42. void __fastcall TfmToolbar::Cascade1Click(TObject *Sender)
  43. {
  44.   Cascade();
  45. }
  46. //---------------------------------------------------------------------
  47. void __fastcall TfmToolbar::First1Click(TObject *Sender)
  48. {
  49.   DBNavigator1->BtnClick(nbFirst);
  50.   UpdateMenu();
  51. }
  52. //---------------------------------------------------------------------
  53. void __fastcall TfmToolbar::Next1Click(TObject *Sender)
  54. {
  55.   DBNavigator1->BtnClick(nbNext);
  56.   UpdateMenu();
  57. }
  58. //---------------------------------------------------------------------
  59. void __fastcall TfmToolbar::Prior1Click(TObject *Sender)
  60. {
  61.   DBNavigator1->BtnClick(nbPrior);
  62.   UpdateMenu();
  63. }
  64. //---------------------------------------------------------------------
  65. void __fastcall TfmToolbar::Last1Click(TObject *Sender)
  66. {
  67.   DBNavigator1->BtnClick(nbLast);
  68.   UpdateMenu();
  69. }
  70. //---------------------------------------------------------------------
  71. void __fastcall TfmToolbar::Delete1Click(TObject *Sender)
  72. {
  73.   DBNavigator1->BtnClick(nbDelete);
  74.   UpdateMenu();
  75. }
  76. //---------------------------------------------------------------------
  77. void __fastcall TfmToolbar::Insert1Click(TObject *Sender)
  78. {
  79.   DBNavigator1->BtnClick(nbInsert);
  80.   UpdateMenu();
  81. }
  82. //---------------------------------------------------------------------
  83. void __fastcall TfmToolbar::Cancel1Click(TObject *Sender)
  84. {
  85.   DBNavigator1->BtnClick(nbCancel);
  86.   UpdateMenu();
  87. }
  88. //---------------------------------------------------------------------
  89. void __fastcall TfmToolbar::SetNavigator(const TDataSource* ds)
  90. {
  91.   if(DBNavigator1->DataSource != ds){
  92.     if(Messages1->Checked)
  93.       ShowMessage(AnsiString("Changing DBNavigator's datasource to ") + ds->Name);
  94.     DBNavigator1->DataSource = (TDataSource*) ds;
  95.     UpdateMenu();
  96.    }
  97.  
  98. }
  99. //---------------------------------------------------------------------
  100. void __fastcall TfmToolbar::UpdateMenu()
  101. {
  102.   First1->Enabled = !DBNavigator1->DataSource->DataSet->Bof;
  103.   Next1->Enabled = !DBNavigator1->DataSource->DataSet->Eof;
  104.   Prior1->Enabled = !DBNavigator1->DataSource->DataSet->Bof;
  105.   Last1->Enabled = !DBNavigator1->DataSource->DataSet->Eof;
  106.   Insert1->Enabled = DBNavigator1->DataSource->DataSet->State == dsBrowse;
  107.   Delete1->Enabled = DBNavigator1->DataSource->DataSet->State == dsBrowse;
  108.   Cancel1->Enabled = DBNavigator1->DataSource->DataSet->State == dsEdit ||
  109.                      DBNavigator1->DataSource->DataSet->State == dsInsert;
  110. }
  111. //---------------------------------------------------------------------
  112.  
  113. void __fastcall TfmToolbar::FormShow(TObject *Sender)
  114. {
  115.   UpdateMenu();    
  116. }
  117. //---------------------------------------------------------------------
  118.