WIZARD.CPP
//----------------------------------------------------------------------------- 
// Microsoft OLE DB TABLECOPY Sample 
// Copyright (C) 1996 By Microsoft Corporation. 
// 
// @doc 
// 
// @module WIZARD.CPP 
// 
//----------------------------------------------------------------------------- 
 
 
///////////////////////////////////////////////////////////////// 
// Includes 
// 
///////////////////////////////////////////////////////////////// 
#include "common.h" 
#include "tablecopy.h" 
#include "wizard.h" 
#include "progress.h" 
 
 
 
///////////////////////////////////////////////////////////////// 
// Defines 
// 
///////////////////////////////////////////////////////////////// 
enum WIZ_STEP 
{ 
WIZ_STEP1= 0, 
WIZ_STEP2= 1, 
WIZ_STEP3= 2, 
WIZ_STEP4= 3, 
WIZ_TYPES= 4, 
END_WIZ= 5 
}; 
 
 
///////////////////////////////////////////////////////////////////// 
// CDialog::CDialog 
// 
///////////////////////////////////////////////////////////////////// 
CDialog::CDialog(HWND hWnd, HINSTANCE hInst) 
{ 
ASSERT(hInst); 
 
m_hWnd= hWnd; 
m_hInst = hInst; 
} 
 
 
///////////////////////////////////////////////////////////////////// 
// CDialog::~CDialog 
// 
///////////////////////////////////////////////////////////////////// 
CDialog::~CDialog() 
{ 
} 
 
 
 
//////////////////////////////////////////////////////////////// 
// CWizard::CWizard 
// 
///////////////////////////////////////////////////////////////// 
CWizard::CWizard(HWND hWnd, HINSTANCE hInst) 
: CDialog(hWnd, hInst) 
{ 
m_pCTableCopy = new CTableCopy(this); 
m_pCProgress = new CProgress(hWnd, hInst); 
} 
 
 
//////////////////////////////////////////////////////////////// 
// CWizard::~CWizard 
// 
///////////////////////////////////////////////////////////////// 
CWizard::~CWizard() 
{ 
delete m_pCTableCopy; 
delete m_pCProgress; 
} 
 
//////////////////////////////////////////////////////////////// 
// ULONG CWizard::FindNextStep 
// 
///////////////////////////////////////////////////////////////// 
ULONG CWizard::FindNextStep(ULONG iStep, ULONG iButton) 
{ 
ASSERT(iStep>=WIZ_STEP1 && iStep<END_WIZ); 
 
//iStep - (the current dialog were in), along with 
//iButton - (button pressed which closed the current dialog) 
 
//From these 2 input, it calculates the next dialog to display 
switch(iButton) 
{ 
case IDOK: 
//if(iStep+1 == END_WIZ) 
//return WIZ_STEP1; 
return iStep + 1; 
 
case IDCANCEL: 
return END_WIZ;    
 
case IDB_PREV: 
return iStep - 1; 
 
default: 
ASSERT(!"Unhandled Case"); 
return END_WIZ; 
}; 
} 
 
//////////////////////////////////////////////////////////////// 
// ULONG CWizard::Run 
// 
///////////////////////////////////////////////////////////////// 
ULONG CWizard::Run() 
{ 
// Call each step. The return value will be either the next 
// step to run or END_WIZARD when we are all done. 
 
ULONG iStep = WIZ_STEP1; 
while(iStep != END_WIZ) 
{ 
switch(iStep) 
{ 
case WIZ_STEP1: 
{ 
CS1Dialog CStep1(m_hWnd, m_hInst, m_pCTableCopy); 
iStep = FindNextStep(iStep, CStep1.Display()); 
break; 
} 
 
case WIZ_STEP2: 
{ 
CS2Dialog CStep2(m_hWnd, m_hInst, m_pCTableCopy); 
iStep = FindNextStep(iStep, CStep2.Display()); 
break; 
} 
 
case WIZ_STEP3: 
{ 
CS3Dialog CStep3(m_hWnd, m_hInst, m_pCTableCopy); 
iStep = FindNextStep(iStep, CStep3.Display()); 
break; 
} 
 
case WIZ_STEP4: 
{ 
CS4Dialog CStep4(m_hWnd, m_hInst, m_pCTableCopy); 
iStep = FindNextStep(iStep, CStep4.Display()); 
break; 
} 
 
case WIZ_TYPES: 
{ 
CTypesDialog CTypes(m_hWnd, m_hInst, m_pCTableCopy); 
iStep = FindNextStep(iStep, CTypes.Display()); 
break; 
} 
 
default: 
{ 
ASSERT(!"Unhandled Case!"); 
break; 
} 
} 
 } 
return iStep; 
}