#ifndef _TFindFieldDlg_CPP_ #define _TFindFieldDlg_CPP_ // INCLUDES #include #include #include #include "db/db.h" // NAME: TFindFieldDlg.H // TYPE: C++ CLASS // DESCRIPTION: Interface for the TFindFieldDlg class // EXAMPLES: // BUGS: // SEE ALSO: //--------------------------------------------------------------------------- const int BTN_FIND_FIELD = 102; const int FIND_FLD_EDIT = 105; const int FIND_DLG = 20; // function creates dialog // prototype TDBIt& FindFieldDialog(TWindow* parent, TDBIt& it, TDatabase& db); class TFindFieldDlg : public TDialog { public: TButton* findBtn; TEdit* findEdit; // construct/destruct TFindFieldDlg(TWindow* parent, TResId resId, TDBIt& it, TDatabase& db) : TDialog(parent, resId), TWindow(parent), d(db), iter(it) { findBtn = new TButton(this, BTN_FIND_FIELD); findEdit= new TEdit(this, FIND_FLD_EDIT); } ~TFindFieldDlg() { delete findBtn; delete findEdit; } // methods void EvBnClicked(); protected: private: TDatabase& d; TDBIt& iter; DECLARE_RESPONSE_TABLE(TFindFieldDlg); }; DEFINE_RESPONSE_TABLE2(TFindFieldDlg, TDialog, TWindow) EV_BN_CLICKED(BTN_FIND_FIELD, EvBnClicked), END_RESPONSE_TABLE; // // methods // ~~~~~~~ void TFindFieldDlg::EvBnClicked() { if( !findEdit->IsModified() ) { MessageBox("No text Entered", "Find Company Name"); return; } else { char buf[100]; TDBIt temp =d.end(); findEdit->GetText( buf, 100 ); if( (temp =d.find( buf ) ) != d.end() ) { iter =temp; CmOk(); } else MessageBox("Not Found", "Find Company Name"); } } // function creates dialog // prototype TDBIt& FindFieldDialog(TWindow* parent, TDBIt& it, TDatabase& db) { TFindFieldDlg dlg(parent, FIND_DLG, it, db); dlg.Execute(); return it; }; #endif // _TFindFieldDlg_CPP_