home *** CD-ROM | disk | FTP | other *** search
- Save Format v1.3
- @begin ClassFile "ApplicationClass"
- Exported 0;
-
- @begin-code BaseClassList
-
- public WExeApplication
-
- @end-code;
-
- @begin UserFunction "ApplicationClass()"
- Compiler 1;
- GencodeFunction 1;
- GencodeSrcLine 16;
- FunctionName "ApplicationClass::ApplicationClass()";
- @end;
-
- @begin UserFunction "~ApplicationClass()"
- Compiler 1;
- GencodeFunction 1;
- GencodeSrcLine 33;
- FunctionName "ApplicationClass::~ApplicationClass()";
- @end;
-
- @begin UserFunction "__DefaultStartHandler( WObject *, WStartEventData *event )"
- Compiler 1;
- GencodeFunction 1;
- GencodeSrcLine 36;
- FunctionName "ApplicationClass::__DefaultStartHandler( WObject *, WStartEventData *event )";
- @end;
-
- @begin UserFunction "__DefaultRunHandler( WObject *, WRunEventData *event )"
- Compiler 1;
- GencodeFunction 1;
- GencodeSrcLine 49;
- FunctionName "ApplicationClass::__DefaultRunHandler( WObject *, WRunEventData *event )";
- @end;
-
- @begin UserFunction "__DefaultEndHandler( WObject *, WEndEventData *event )"
- Compiler 1;
- GencodeFunction 1;
- GencodeSrcLine 54;
- FunctionName "ApplicationClass::__DefaultEndHandler( WObject *, WEndEventData *event )";
- @end;
-
- @begin UserFunction "StartHandler( WObject *, WStartEventData *event )"
- Compiler 1;
- GencodeSrcLine 63;
- FunctionName "ApplicationClass::StartHandler( WObject *, WStartEventData *event )";
- @end;
-
- @begin UserFunction "RunHandler( WObject *, WRunEventData *event )"
- Compiler 1;
- GencodeSrcLine 140;
- FunctionName "ApplicationClass::RunHandler( WObject *, WRunEventData *event )";
- @end;
-
- @begin UserFunction "EndHandler( WObject *, WEndEventData *event )"
- Compiler 1;
- GencodeSrcLine 144;
- FunctionName "ApplicationClass::EndHandler( WObject *, WEndEventData *event )";
- @end;
-
- @begin HPPPrefixBlock
- @begin-code HPPPrefix
-
- class Form1;
-
- @end-code;
- GencodeSrcLine 11;
- @end;
-
- @begin CPPPrefixBlock
- @begin-code CPPPrefix
-
- // Code added here will be included at the top of the .CPP file
- #include "ODBCAdmin.hpp"
-
- // Include definitions for resources.
- #include "WRes.h"
-
- @end-code;
- GencodeSrcLine 11;
- @end;
-
- @begin ClassContentsBlock
- @begin-code ClassContents
-
- public:
- // add your public instance data here
- private:
- // add your private instance data here
- protected:
- // add your protected instance data here
-
- @end-code;
- GencodeSrcLine 24;
- @end;
-
- @begin-code GeneratedClassContents
-
- ApplicationClass();
- ~ApplicationClass();
- WBool __DefaultStartHandler( WObject *, WStartEventData *event );
- WBool __DefaultRunHandler( WObject *, WRunEventData *event );
- WBool __DefaultEndHandler( WObject *, WEndEventData *event );
- WBool StartHandler( WObject *, WStartEventData *event );
- WBool RunHandler( WObject *, WRunEventData *event );
- WBool EndHandler( WObject *, WEndEventData *event );
- WBool __DefaultStartHandler( WObject *, WStartEventData *event );
- WBool __DefaultRunHandler( WObject *, WRunEventData *event );
- WBool __DefaultEndHandler( WObject *, WEndEventData *event );
-
- @end-code;
-
- @begin-code Code "ApplicationClass::ApplicationClass()"
-
- @@CLASSNAME@::@CLASSNAME@()
- {
- SetEventHandler( WStartEvent, this,
- (WEventHandler) __DefaultStartHandler );
- SetEventHandler( WStartEvent, this,
- (WEventHandler) StartHandler );
-
- SetEventHandler( WRunEvent, this,
- (WEventHandler) __DefaultRunHandler );
- SetEventHandler( WRunEvent, this,
- (WEventHandler) RunHandler );
-
- SetEventHandler( WEndEvent, this,
- (WEventHandler) __DefaultEndHandler );
- SetEventHandler( WEndEvent, this,
- (WEventHandler) EndHandler );
- }
-
- @end-code;
-
- @begin-code Code "ApplicationClass::~ApplicationClass()"
-
- @@CLASSNAME@::~@CLASSNAME@()
- {
- }
-
- @end-code;
-
- @begin-code Code "ApplicationClass::__DefaultStartHandler( WObject *, WStartEventData *event )"
-
- WBool @CLASSNAME@::__DefaultStartHandler( WObject *, WStartEventData *event )
- {
- extern WForm *__MainForm;
- class Form1;
- extern WForm *_CreateForm1(void);
-
- __MainForm = _CreateForm1();
- if( __MainForm == NULL ) {
- event->abortRun = TRUE;
- event->exitCode = -1;
- }
- return TRUE;
- }
-
- @end-code;
-
- @begin-code Code "ApplicationClass::__DefaultRunHandler( WObject *, WRunEventData *event )"
-
- WBool @CLASSNAME@::__DefaultRunHandler( WObject *, WRunEventData *event )
- {
- WCurrentThread::ProcessMessages();
- return TRUE;
- }
-
- @end-code;
-
- @begin-code Code "ApplicationClass::__DefaultEndHandler( WObject *, WEndEventData *event )"
-
- WBool @CLASSNAME@::__DefaultEndHandler( WObject *, WEndEventData *event )
- {
- extern WForm *__MainForm;
- extern void _DeleteForm1( WForm *);
-
- _DeleteForm1( __MainForm );
- __MainForm = NULL;
- return TRUE;
- }
-
- @end-code;
-
- @begin-code Code "ApplicationClass::StartHandler( WObject *, WStartEventData *event )"
-
- static WChar Driver[] = WTEXT("Microsoft Access Driver (*.mdb)");
- static WChar Datasource[] = WTEXT("Microsoft Access 7.0 Sample");
- static WChar DBFile[] = WTEXT("Northwind.mdb");
-
- static WChar* keyValues[] = {
- WTEXT("DriverId"),WTEXT("25"),
- WTEXT("FIL"),WTEXT("MS Access"),
- WTEXT("UID"),WTEXT("admin"),
- NULL
- };
-
-
- WBool @CLASSNAME@::StartHandler( WObject *, WStartEventData *event )
- {
-
- WString driver_dll;
- WStringArray keys;
- WString db_file;
- WFilePath path;
- WString dir;
- WString pathKey;
-
- WRegistryKey regKey;
- WInt i;
-
- //
- // So that the user can go into the Sample and read the programming tips.
- //
- event->abortRun = FALSE;
-
- if( !ODBCAdmin::DriverExists( Driver, driver_dll ) ) {
- WMessageBox::Messagef( NULL, WMBLevelError, WMBButtonOk, "Driver Error",
- "The ODBC Driver '%s' is not installed. Data source cannot "\
- "be created. "\
- "Please read the programming tips in this sample on instructions to install the driver",
- Driver );
- return FALSE;
- }
-
- for ( i=0; keyValues[i]; i++ );
- keys.SetCount(i+4);
- for ( i=0; keyValues[i]; i++ ) {
- keys[i] = keyValues[i];
- }
- keys[i] = WTEXT( "Driver" );
- keys[i+1] = driver_dll;
- keys[i+2] = WTEXT( "DBQ" );
-
- pathKey = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\MSACCESS.EXE";
- if ( regKey.Open( WRKeyLocalMachine, pathKey ) ) {
- path = regKey.GetStringValue("Path");
- path += "Samples\\";
- regKey.Close();
- } else {
- return FALSE;
- }
-
- path.SetFileName( DBFile );
- if( !path.Exists() ) {
- WMessageBox::Messagef(NULL, WMBLevelError, WMBButtonOk, "Data source Error",
- "The data file '%s' could not be found", path.GetText() );
-
- return( FALSE );
- }
- keys[i+3] = path;
-
- if( !ODBCAdmin::AddDataSource( Datasource, Driver, keys ) ) {
- WMessageBox::Messagef( NULL, WMBLevelError, WMBButtonOk, "Data source Error",
- "The ODBC Datasource '%s' could not be installed", Datasource );
- return( FALSE );
- }
-
-
-
- event->exitCode = 0;
- return FALSE;
- }
-
- @end-code;
-
- @begin-code Code "ApplicationClass::RunHandler( WObject *, WRunEventData *event )"
-
- WBool @CLASSNAME@::RunHandler( WObject *, WRunEventData *event )
- {
- return FALSE;
- }
-
- @end-code;
-
- @begin-code Code "ApplicationClass::EndHandler( WObject *, WEndEventData *event )"
-
- WBool @CLASSNAME@::EndHandler( WObject *, WEndEventData *event )
- {
- return FALSE;
- }
-
- @end-code;
- @end;
-