#include <Symbol.h>
#include <Myframe.h>

#include <Wizard.h>
extern BOOL bAfxMono;


int far Page1(void *pUser)
{
    CWizard* pWizard = (CWizard *)pUser;

	//Create a Dialog On the Center of Desktop
	CDialog* pDialog = new CDialog;//分配实例
	pDialog->CreateWindow(pWizard->GetRect()->left,
        pWizard->GetRect()->top, 321, 240, "第一页：1");//建立窗口
    	pWizard->SetRect(&pDialog->m_ScreenRect);

	//Create Close's Button Control
	CCloseButton* pCloseButton = new CCloseButton(pDialog);//分配和建立关闭按钮

	//Create a Button Control
    CButton* pButton1 = new CButton(pDialog);
	pButton1->CreateObject(10, 199, 93, 24, "上一步(\x3P\x3)");
	pButton1->SetShortcutKey(VK_ALT_P);
 	pButton1->SetFc(ClickNoButton);

	//Create a Button Control
	CButton* pButton2 = new CButton(pDialog);
	pButton2->CreateObject(111, 199, 93, 24, "下一步(\x3N\x3)");
	pButton2->SetShortcutKey(VK_ALT_N);
 	pButton2->SetFc(ClickYesButton);
 	pButton2->SetDefaultFlags(TRUE);

	//Create a Button Control
	CButton* pButton3 = new CButton(pDialog);
	pButton3->CreateObject(211, 199, 93, 24, "退出(\x3\C\x3)");
	pButton3->SetShortcutKey(VK_ALT_C);
	pButton3->SetFc(ClickCancelButton);

    if (pWizard->GetOrder() == 0)
    {
        pButton1->SetEnable(FALSE);
    }
    else if (pWizard->GetOrder() + 1 == pWizard->GetPages())
    {
        pButton2->SetEnable(FALSE);
    }

	//Create Radio Control
	CRadio* pRadio1 = new CRadio(pDialog);
	pRadio1->CreateObject(28, 59, 57, 24, "男姓");
	pRadio1->SetStatic(TRUE);
	pRadio1->SetRadio(TRUE);
	pRadio1->SetID(RADIOBASE + 1 - 1);

	//Create Radio Control
	CRadio* pRadio2 = new CRadio(pDialog);
	pRadio2->CreateObject(100, 61, 57, 24, "女性");
	pRadio2->SetID(RADIOBASE + 2 - 1);

	//Create Radio Control
	CRadio* pRadio3 = new CRadio(pDialog);
	pRadio3->CreateObject(171, 61, 57, 24, "保密");
	pRadio3->SetID(RADIOBASE + 3 - 1);

    pRadio1->SetCurSel(1, FALSE);

	//Create Radio Control
	CRadio* pRadio4 = new CRadio(pDialog);
	pRadio4->CreateObject(28, 148, 57, 24, "大专");
	pRadio4->SetStatic(TRUE);
	pRadio4->SetRadio(TRUE);
	pRadio4->SetID(RADIOBASE + 4 - 1);

	//Create Radio Control
	CRadio* pRadio5 = new CRadio(pDialog);
	pRadio5->CreateObject(100, 148, 57, 24, "本科");
	pRadio5->SetID(RADIOBASE + 5 - 1);

	//Create Radio Control
	CRadio* pRadio6 = new CRadio(pDialog);
	pRadio6->CreateObject(169, 148, 57, 24, "硕士");
	pRadio6->SetID(RADIOBASE + 6 - 1);

	//Create Radio Control
	CRadio* pRadio7 = new CRadio(pDialog);
	pRadio7->CreateObject(229, 147, 57, 24, "博士");
	pRadio7->SetID(RADIOBASE + 7 - 1);

    pRadio4->SetCurSel(2, FALSE);

	//Create Group Control
	CStatic* pGroup1 = new CStatic(pDialog);
	pGroup1->CreateObject(10, 29, 285, 67, "性别");

	//Create Group Control
	CStatic* pGroup2 = new CStatic(pDialog);
	pGroup2->CreateObject(10, 118, 285, 66, "学位");

	//Show Window
    //pDialog->SetSaveScreen(FALSE);
	pDialog->ShowWindow();//显示窗口

	//go into Message Loop
    int nResult = IDNULL;
    do
    {
        nResult = pDialog->DoModal();//进入窗口消息循环
        if (nResult == IDYES)
        {
        }
        else if (nResult == IDNO)
        {
        }

        break;
    } while(1);
    pDialog->GetScreenRect(pWizard->GetRect());


    char buf[150];
    sprintf(buf,   "第一组你选择了第 %d 项,内容为＂%s＂\n"
                 "\n第二组你选择了第 %d 项,内容为＂%s＂\n",
            pRadio1->GetCurSel(),
            pRadio1->GetSelRadio()->GetCaption(),
            pRadio4->GetCurSel(),
            pRadio4->GetSelRadio()->GetCaption());


	//Destroy Window
	delete pDialog;//删除对话框


    if (nResult == IDYES || nResult == IDNO)
    {
        char buf2[30];
        sprintf (buf2, "第%d页结果", 1 + pWizard->GetOrder());
        AfxMessageBox (buf2, buf);
    }

	return (nResult);

}

int far Page2(void *pUser)
{
    CWizard* pWizard = (CWizard *)pUser;

	//Create a Dialog On the Center of Desktop
	CDialog* pDialog = new CDialog;//分配实例
	pDialog->CreateWindow(pWizard->GetRect()->left,
        pWizard->GetRect()->top, 321, 240, "第二页:2");//建立窗口
    pWizard->SetRect(&pDialog->m_ScreenRect);

	//Create Close's Button Control
	CCloseButton* pCloseButton = new CCloseButton(pDialog);//分配和建立关闭按钮

	//Create a Button Control
    CButton* pButton1 = new CButton(pDialog);
	pButton1->CreateObject(10, 199, 93, 24, "上一步(\x3P\x3)");
	pButton1->SetShortcutKey(VK_ALT_P);
 	pButton1->SetFc(ClickNoButton);

	//Create a Button Control
	CButton* pButton2 = new CButton(pDialog);
	pButton2->CreateObject(111, 199, 93, 24, "下一步(\x3N\x3)");
	pButton2->SetShortcutKey(VK_ALT_N);
 	pButton2->SetFc(ClickYesButton);
 	pButton2->SetDefaultFlags(TRUE);

	//Create a Button Control
	CButton* pButton3 = new CButton(pDialog);
	pButton3->CreateObject(211, 199, 93, 24, "退出(\x3\C\x3)");
	pButton3->SetShortcutKey(VK_ALT_C);
	pButton3->SetFc(ClickCancelButton);

    if (pWizard->GetOrder() == 0)
    {
        pButton1->SetEnable(FALSE);
    }
    else if (pWizard->GetOrder() + 1 == pWizard->GetPages())
    {
        pButton2->SetEnable(FALSE);
    }

	//Create Radio Control
	CRadio* pRadio1 = new CRadio(pDialog);
	pRadio1->CreateObject(28, 64, 57, 24, "北京");
	pRadio1->SetStatic(TRUE);
	pRadio1->SetRadio(TRUE);
	pRadio1->SetID(RADIOBASE + 1 - 1);

	//Create Radio Control
	CRadio* pRadio2 = new CRadio(pDialog);
	pRadio2->CreateObject(100, 65, 57, 24, "上海");
	pRadio2->SetID(RADIOBASE + 2 - 1);

	//Create Radio Control
	CRadio* pRadio3 = new CRadio(pDialog);
	pRadio3->CreateObject(171, 65, 57, 24, "广州");
	pRadio3->SetID(RADIOBASE + 3 - 1);

	//Create Combo Control
	CComboBox* pComboBox1 = new CComboBox(pDialog);
	pComboBox1->CreateCombo(124, 122, 169, 24, NULL);
	pComboBox1->SetID(COMBOBASE + 1 - 1);


	//Create Group Control
	CStatic* pGroup1 = new CStatic(pDialog);
	pGroup1->CreateObject(10, 34, 285, 67, "籍贯");

	//Create a Label Control
	CLabel* pLabel1 = new CLabel(pDialog);
	pLabel1->CreateObject(13, 125, 67, 12, "选择年份(N)");

    //------------------------------------------------------
    char buf[150];
    pComboBox1->SetCount(10);
    for (int i = 0; i < 10; i++)
    {
        sprintf (buf, "%04d年", 1970 + i);
        pComboBox1->SetSel(i, buf);
    }
    pComboBox1->SetIndex (5);

	//Show Window
    //pDialog->SetSaveScreen(FALSE);
	pDialog->ShowWindow();//显示窗口

	//go into Message Loop
    int nResult = IDNULL;
    do
    {
        nResult = pDialog->DoModal();//进入窗口消息循环
        if (nResult == IDYES)
        {
        }
        else if (nResult == IDNO)
        {
        }

        break;
    } while(1);
   pDialog->GetScreenRect(pWizard->GetRect());


   sprintf (buf, "你的籍贯是:%s，出生与%s",
           pRadio1->GetSelRadio()->GetCaption(),
           pComboBox1->GetSel(pComboBox1->GetIndex()));

	//Destroy Window
	delete pDialog;//删除对话框

    if (nResult == IDYES || nResult == IDNO)
    {
        char buf2[30];
        sprintf (buf2, "第%d页结果", 1 + pWizard->GetOrder());
        AfxMessageBox (buf2, buf);
    }

	return (nResult);

}

int far Page3(void *pUser)
{
    CWizard* pWizard = (CWizard *)pUser;

	//Create a Dialog On the Center of Desktop
	CDialog* pDialog = new CDialog;//分配实例
	pDialog->CreateWindow(pWizard->GetRect()->left,
        pWizard->GetRect()->top, 321, 240, "第二页:2");//建立窗口
    pWizard->SetRect(&pDialog->m_ScreenRect);

	//Create Close's Button Control
	CCloseButton* pCloseButton = new CCloseButton(pDialog);//分配和建立关闭按钮

	//Create a Button Control
    CButton* pButton1 = new CButton(pDialog);
	pButton1->CreateObject(10, 199, 93, 24, "上一步(\x3P\x3)");
	pButton1->SetShortcutKey(VK_ALT_P);
 	pButton1->SetFc(ClickNoButton);

	//Create a Button Control
	CButton* pButton2 = new CButton(pDialog);
	pButton2->CreateObject(111, 199, 93, 24, "下一步(\x3N\x3)");
	pButton2->SetShortcutKey(VK_ALT_N);
 	pButton2->SetFc(ClickYesButton);
 	pButton2->SetDefaultFlags(TRUE);

	//Create a Button Control
	CButton* pButton3 = new CButton(pDialog);
	pButton3->CreateObject(211, 199, 93, 24, "退出(\x3\C\x3)");
	pButton3->SetShortcutKey(VK_ALT_C);
	pButton3->SetFc(ClickCancelButton);

    if (pWizard->GetOrder() == 0)
    {
        pButton1->SetEnable(FALSE);
    }
    else if (pWizard->GetOrder() + 1 == pWizard->GetPages())
    {
        pButton2->SetEnable(FALSE);
    }

	//Create Slider Control
	CSliderCtrl* pSliderCtrl1 = new CSliderCtrl(pDialog);
	pSliderCtrl1->CreateObject(37, 153, 241, 24, NULL);
	pSliderCtrl1->SetID(SLIDERBASE + 1 - 1);
	pSliderCtrl1->SetHorz(TRUE);

	//Create Slider Control
	CSliderCtrl* pSliderCtrl2 = new CSliderCtrl(pDialog);
	pSliderCtrl2->CreateObject(72, 29, 30, 99, NULL);
	pSliderCtrl2->SetID(SLIDERBASE + 2 - 1);
	pSliderCtrl2->SetHorz(FALSE);


	//Create Edit Control
	CEdit* pEdit1 = new CEdit(pDialog);
	pEdit1->CreateObject(202, 77, 60, 21, NULL);
	pEdit1->SetID(EDITBASE + 1 - 1);

	//Create Spin Control
	CSpinCtrl* pSpinCtrl1 = new CSpinCtrl(pDialog);
	pSpinCtrl1->CreateObject(264, 77, 19, 21, NULL);
	pSpinCtrl1->SetID(SPINBASE + 1 - 1);
	pSpinCtrl1->SetHorz(FALSE);
	pSpinCtrl1->SetRange(1Lu, 10Lu);
	pSpinCtrl1->SetSpin(5);
	pSpinCtrl1->SetBody(pEdit1);

	//Show Window
    //pDialog->SetSaveScreen(FALSE);
	pDialog->ShowWindow();//显示窗口

	//go into Message Loop
    int nResult = IDNULL;
    do
    {
        nResult = pDialog->DoModal();//进入窗口消息循环
        if (nResult == IDYES)
        {
        }
        else if (nResult == IDNO)
        {
        }

        break;
    } while(1);
   pDialog->GetScreenRect(pWizard->GetRect());


   char buf[150];
   sprintf (buf, "你的计数器的计数值是:%d",
           pSpinCtrl1->GetSpin());

	//Destroy Window
	delete pDialog;//删除对话框

    if (nResult == IDYES || nResult == IDNO)
    {
        char buf2[30];
        sprintf (buf2, "第%d页结果", 1 + pWizard->GetOrder());
        AfxMessageBox (buf2, buf);
    }

	return(nResult);

}

void far ClickScrolH_Left_Page4(CHScrollBar* pScrollBarH)
{
    CDialog* pDialog = (CDialog *)pScrollBarH->GetParent();
	CLabel* pLabel2 = (CLabel *)pDialog->ObjectFromID(LABELBASE + 2 - 1);

    DWORD dwPos, dwMin, dwMax;
    pScrollBarH->GetRange(&dwMin, &dwMax);
    dwPos = pScrollBarH->GetPos();
    if (dwPos <= dwMin)
    {
        return;
    }

    pScrollBarH->SetPos(--dwPos);
    pScrollBarH->Paint();

    char buf[100];
    sprintf(buf, "横向滚动条：%03lu-(%03lu-%03lu)", dwPos, dwMin, dwMax);
    pLabel2->SetWindowText(buf);
    pLabel2->SetBackColorDisplay(TRUE);
    pLabel2->Show();
}

void far ClickScrolH_Pos_Page4(CHScrollBar* pScrollBarH)
{
    CDialog* pDialog = (CDialog *)pScrollBarH->GetParent();
	CLabel* pLabel2 = (CLabel *)pDialog->ObjectFromID(LABELBASE + 2 - 1);

    DWORD dwPos, dwMin, dwMax;
    pScrollBarH->GetRange(&dwMin, &dwMax);
    dwPos = pScrollBarH->GetPos();

    char buf[100];
    sprintf(buf, "横向滚动条：%03lu-(%03lu-%03lu)", dwPos, dwMin, dwMax);
    pLabel2->SetWindowText(buf);
    pLabel2->SetBackColorDisplay(TRUE);
    pLabel2->Show();
}

void far ClickScrolH_Right_Page4(CHScrollBar* pScrollBarH)
{
    CDialog* pDialog = (CDialog *)pScrollBarH->GetParent();
	CLabel* pLabel2 = (CLabel *)pDialog->ObjectFromID(LABELBASE + 2 - 1);

    DWORD dwPos, dwMin, dwMax;
    pScrollBarH->GetRange(&dwMin, &dwMax);
    dwPos = pScrollBarH->GetPos();

    if (dwPos >= dwMax)
    {
        return;
    }

    pScrollBarH->SetPos(++dwPos);
    pScrollBarH->Paint();


    char buf[100];
    sprintf(buf, "横向滚动条：%03lu-(%03lu-%03lu)", dwPos, dwMin, dwMax);
    pLabel2->SetWindowText(buf);
    pLabel2->SetBackColorDisplay(TRUE);
    pLabel2->Show();



}

void far ClickScrolV_Top_Page4(CVScrollBar* pScrollBarV)
{
    CDialog* pDialog = (CDialog *)pScrollBarV->GetParent();
	CLabel* pLabel1 = (CLabel *)pDialog->ObjectFromID(LABELBASE + 1 - 1);

    DWORD dwPos, dwMin, dwMax;
    pScrollBarV->GetRange(&dwMin, &dwMax);
    dwPos = pScrollBarV->GetPos();
    if (dwPos <= dwMin)
    {
        return;
    }

    pScrollBarV->SetPos(--dwPos);
    pScrollBarV->Paint();

    char buf[100];
    sprintf(buf, "纵向滚动条：%03lu-(%03lu-%03lu)", dwPos, dwMin, dwMax);
    pLabel1->SetWindowText(buf);
    pLabel1->SetBackColorDisplay(TRUE);
    pLabel1->Show();
}

void far ClickScrolV_Pos_Page4(CVScrollBar* pScrollBarV)
{
    CDialog* pDialog = (CDialog *)pScrollBarV->GetParent();
	CLabel* pLabel1 = (CLabel *)pDialog->ObjectFromID(LABELBASE + 1 - 1);

    DWORD dwPos, dwMin, dwMax;
    pScrollBarV->GetRange(&dwMin, &dwMax);
    dwPos = pScrollBarV->GetPos();

    char buf[100];
    sprintf(buf, "纵向滚动条：%03lu-(%03lu-%03lu)", dwPos, dwMin, dwMax);
    pLabel1->SetWindowText(buf);
    pLabel1->SetBackColorDisplay(TRUE);
    pLabel1->Show();
}

void far ClickScrolV_Bottom_Page4(CVScrollBar* pScrollBarV)
{
    CDialog* pDialog = (CDialog *)pScrollBarV->GetParent();
	CLabel* pLabel1 = (CLabel *)pDialog->ObjectFromID(LABELBASE + 1 - 1);

    DWORD dwPos, dwMin, dwMax;
    pScrollBarV->GetRange(&dwMin, &dwMax);
    dwPos = pScrollBarV->GetPos();

    if (dwPos >= dwMax)
    {
        return;
    }

    pScrollBarV->SetPos(++dwPos);
    pScrollBarV->Paint();


    char buf[100];
    sprintf(buf, "纵向滚动条：%03lu-(%03lu-%03lu)", dwPos, dwMin, dwMax);
    pLabel1->SetWindowText(buf);
    pLabel1->SetBackColorDisplay(TRUE);
    pLabel1->Show();



}

int far Page4(void* pUser)
{
    CWizard* pWizard = (CWizard *)pUser;

	//Create a Dialog On the Center of Desktop
	CDialog* pDialog = new CDialog;//分配实例
	pDialog->CreateWindow(pWizard->GetRect()->left,
        pWizard->GetRect()->top, 321, 240, "第四页:4");//建立窗口
    pWizard->SetRect(&pDialog->m_ScreenRect);

	//Register Callback Function for Window
	pDialog->SetTimeFc(NULL);//注册定时器回调函数
	pDialog->SetDrawFc(NULL);//注册画图回调函数
	pDialog->SetHelpFc(NULL);//注册帮助回调函数
	pDialog->SetKeyboardFc(NULL);//注册虚拟键盘回调函数

	//Create Close's Button Control
	CCloseButton* pCloseButton = new CCloseButton(pDialog);//分配和建立关闭按钮

	//Create a Button Control
	CButton* pButton1 = new CButton(pDialog);
	pButton1->CreateObject(43, 177, 108, 24, "上一步(\x3P\x3)");
	pButton1->SetShortcutKey(VK_ALT_P);
	pButton1->SetID(BUTTONBASE + 1 - 1);
 	pButton1->SetFc(ClickNoButton);

	//Create a Button Control
	CButton* pButton2 = new CButton(pDialog);
	pButton2->CreateObject(43, 201, 108, 24, "下一步(\x3N\x3)");
	pButton2->SetShortcutKey(VK_ALT_N);
	pButton2->SetID(BUTTONBASE + 2 - 1);
 	pButton2->SetFc(ClickYesButton);

	//Create a Button Control
	CButton* pButton3 = new CButton(pDialog);
	pButton3->CreateObject(177, 177, 108, 24, "确认(\x3\E\x3)");
	pButton3->SetShortcutKey(VK_ALT_E);
	pButton3->SetFc(ClickEnterButton);
	pButton3->SetID(BUTTONBASE + 3 - 1);
 	pButton3->SetFc(ClickEnterButton);

	//Create a Button Control
	CButton* pButton4 = new CButton(pDialog);
	pButton4->CreateObject(177, 201, 108, 24, "退出(\x3\C\x3)");
	pButton4->SetShortcutKey(VK_ALT_C);
	pButton4->SetFc(ClickCancelButton);
	pButton4->SetID(BUTTONBASE + 4 - 1);
 	pButton4->SetFc(ClickCancelButton);

    if (pWizard->GetOrder() == 0)
    {
        pButton1->SetEnable(FALSE);
    }
    else if (pWizard->GetOrder() + 1 == pWizard->GetPages())
    {
        pButton2->SetEnable(FALSE);
    }

	//Create Verz ScrollBar Control
	CVScrollBar* pScrollBarV1 = new CVScrollBar(pDialog);
	pScrollBarV1->CreateScrollBar(28, 28, 15, 126);
	pScrollBarV1->SetID(VSCROLLBASE + 1 - 1);
	pScrollBarV1->SetBackColor(DARKGRAY);

	//Create Horz ScroolBar Control
	CHScrollBar* pScrollBarH1 = new CHScrollBar(pDialog);
	pScrollBarH1->CreateScrollBar(55, 138, 249, 16);
	pScrollBarH1->SetID(HSCROLLBASE + 1 - 1);
	pScrollBarH1->SetBackColor(DARKGRAY);


	//Create a Label Control
	CLabel* pLabel1 = new CLabel(pDialog);
	pLabel1->CreateObject(94, 73, 139, 12, "纵向滚动条：000-(000-000)");
	pLabel1->SetID(LABELBASE + 1 - 1);

	//Create a Label Control
	CLabel* pLabel2 = new CLabel(pDialog);
	pLabel2->CreateObject(94, 101, 139, 12, "横向滚动条：000-(000-000)");
	pLabel2->SetID(LABELBASE + 2 - 1);

    //=======================================================

    pScrollBarH1->SetRange(100,200);
    pScrollBarH1->SetPos(150);
    pScrollBarH1->SetScrollLeftFc(::ClickScrolH_Left_Page4);
    pScrollBarH1->SetScrollPosFc(::ClickScrolH_Pos_Page4);
    pScrollBarH1->SetScrollRightFc(::ClickScrolH_Right_Page4);


    pScrollBarV1->SetRange(300,500);
    pScrollBarV1->SetPos(400);
    pScrollBarV1->SetScrollTopFc(::ClickScrolV_Top_Page4);
    pScrollBarV1->SetScrollPosFc(::ClickScrolV_Pos_Page4);
    pScrollBarV1->SetScrollBottomFc(::ClickScrolV_Bottom_Page4);

	//Show Window
	pDialog->ShowWindow();//显示窗口

    ::ClickScrolH_Pos_Page4(pScrollBarH1);
    ::ClickScrolV_Pos_Page4(pScrollBarV1);

	//go into Message Loop
    int nResult = IDNULL;
    do
    {
        nResult = pDialog->DoModal();//进入窗口消息循环
        if (nResult == IDYES)
        {
        }
        else if (nResult == IDNO)
        {
        }
        else if (nResult == IDOK)
        {
        }

        break;
    } while(1);
   pDialog->GetScreenRect(pWizard->GetRect());

	//Destroy Window 
	delete pDialog;//删除对话框


	return(nResult);

}

void DemoWizard()
{
    CWizard *pWizard = new CWizard;
    pWizard->CreateObject(0, 0, 321, 240, NULL);
    pWizard->Center();


    pWizard->AddPage(Page1);
    pWizard->AddPage(Page2);
    pWizard->AddPage(Page3);
    pWizard->AddPage(Page4);


    pWizard->DoWizard();

    DELETE(pWizard);
}


