#include <Symbol.h>
#include <MyFrame.h>


void far Demo_NumberKeyboard()
{
	//Create a Dialog On the Center of Desktop
	CDialog* pDialog = new CDialog;//分配实例
	pDialog->CreateWindow(0, 0, 466, 279, "数字键盘演示");//建立窗口
	pDialog->Center();//窗口对中

	//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(39, 232, 385, 24, "退出(\x3\C\x3)");
	pButton1->SetShortcutKey(VK_ALT_C);
	pButton1->SetFc(ClickCancelButton);
	pButton1->SetID(BUTTONBASE + 1 - 1);

	//Create Group Control
	CStatic* pGroup1 = new CStatic(pDialog);
	pGroup1->CreateObject(10, 29, 274, 182, "设置");
	pGroup1->SetID(GROUPBASE + 1 - 1);

	//Create a Label Control
	CLabel* pLabel1 = new CLabel(pDialog);
	pLabel1->CreateObject(21, 71, 25, 12, "生日");
	pLabel1->SetID(LABELBASE + 1 - 1);

	//Create Edit Control
	CEdit* pEdit1 = new CEdit(pDialog);
	pEdit1->CreateObject(67, 71, 51, 21, NULL);
	pEdit1->SetID(EDITBASE + 1 - 1);

	//Create a Label Control
	CLabel* pLabel2 = new CLabel(pDialog);
	pLabel2->CreateObject(123, 71, 13, 12, "年");
	pLabel2->SetID(LABELBASE + 2 - 1);

	//Create Edit Control
	CEdit* pEdit2 = new CEdit(pDialog);
	pEdit2->CreateObject(147, 71, 34, 21, NULL);
	pEdit2->SetID(EDITBASE + 2 - 1);

	//Create a Label Control
	CLabel* pLabel3 = new CLabel(pDialog);
	pLabel3->CreateObject(187, 71, 13, 12, "月");
	pLabel3->SetID(LABELBASE + 3 - 1);

	//Create Edit Control
	CEdit* pEdit3 = new CEdit(pDialog);
	pEdit3->CreateObject(217, 71, 34, 21, NULL);
	pEdit3->SetID(EDITBASE + 3 - 1);

	//Create a Label Control
	CLabel* pLabel4 = new CLabel(pDialog);
	pLabel4->CreateObject(259, 71, 13, 12, "日");
	pLabel4->SetID(LABELBASE + 4 - 1);

	//Create a Label Control
	CLabel* pLabel5 = new CLabel(pDialog);
	pLabel5->CreateObject(21, 112, 25, 12, "手机");
	pLabel5->SetID(LABELBASE + 5 - 1);

	//Create Edit Control
	CEdit* pEdit4 = new CEdit(pDialog);
	pEdit4->CreateObject(67, 112, 184, 21, NULL);
	pEdit4->SetID(EDITBASE + 4 - 1);

	//Create Group Control
	CStatic* pGroup2 = new CStatic(pDialog);
	pGroup2->CreateObject(295, 29, 154, 182, "");
	pGroup2->SetID(GROUPBASE + 2 - 1);

	//Create Group Control
	CStatic* pGroup3 = new CStatic(pDialog);
	pGroup3->CreateObject(10, 219, 439, 46, "");
	pGroup3->SetID(GROUPBASE + 3 - 1);

	//Create a Label Control
	CLabel* pLabel6 = new CLabel(pDialog);
	pLabel6->CreateObject(19, 154, 25, 12, "电话");
	pLabel6->SetID(LABELBASE + 6 - 1);

	//Create Edit Control
	CEdit* pEdit5 = new CEdit(pDialog);
	pEdit5->CreateObject(67, 154, 184, 21, NULL);
	pEdit5->SetID(EDITBASE + 5 - 1);


    //--------------------------------------------
    CNumberKeyboard *pNumberKeyboard = new CNumberKeyboard(pDialog);
    pNumberKeyboard->CreateObject(305, 35, 220, 280, NULL);
    pNumberKeyboard->SetScale(1.0f);

    pEdit1->SetNumberFlags(TRUE);
    pEdit2->SetNumberFlags(TRUE);
    pEdit3->SetNumberFlags(TRUE);
    pEdit4->SetNumberFlags(TRUE);
    pEdit5->SetNumberFlags(TRUE);

    pEdit1->SetMaxCount(4);
    pEdit2->SetMaxCount(2);
    pEdit3->SetMaxCount(2);
    pEdit4->SetMaxCount(12);
    pEdit5->SetMaxCount(20);

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

	//go into Message Loop
	int nResult = pDialog->DoModal();//进入窗口消息循环

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


	return;

}
