#t#在向大家详细介绍Visual Studio编辑框之前,首先让大家了解下传统的软件界面,然后全面介绍Visual Studio编辑框,希望对大家有用。在传统的软件界面中,我们都是通过点击菜单项,或者工具栏上的按钮来简单执行某个命令。在新的Ribbon界面中,我们不仅可以点击按钮,还可以通过Visual Studio编辑框输入数据或者通过ComboBox快速地选择数据等等,完成更加复杂的交互。
如下的代码演示了Visual Studio编辑框的创建过程:
- CMFCRibbonPanel*pPanel1=pCategory->AddPanel(_T(“Standard"));
- //创建简单编辑框
- CMFCRibbonEdit*pBtn1=newCMFCRibbonEdit(ID_RIBBON_EBTN_1,90);
- pBtn1->SetEditText(_T("Edit"));
- pPanel1->Add(pBtn1);
- //创建可调编辑框
- CMFCRibbonEdit*pBtn2=newCMFCRibbonEdit(ID_RIBBON_EBTN_2,90);
- pBtn2->EnableSpinButtons(0,99);
- pBtn2->SetEditText(_T("0"));
- pPanel1->Add(pBtn2);
- //创建ComboBox
- CMFCRibbonComboBox*pBtn3=newCMFCRibbonComboBox(ID_RIBBON_EBTN_3,TRUE,74);
- //添加下拉选项
- pBtn3->AddItem(_T("ComboBox"));
- for(i=0;i<20;i++)
- {
- CStringstr;
- str.Format(_T("Item%d"),i+1);
- pBtn3->AddItem(str);
- }
- pBtn3->SelectItem(0);
- pPanel1->Add(pBtn3);
- CMFCRibbonPanel*pPanel2=pCategory->AddPanel(_T("WithIconsandLabels"));
- //创建带图标的编辑框
- CMFCRibbonEdit*pBtn4=newCMFCRibbonEdit(ID_RIBBON_EBTN_4,90,_T("Label:"),0);
- pBtn4->SetEditText(_T("Edit"));
- pPanel2->Add(pBtn4);
- CMFCRibbonEdit*pBtn5=newCMFCRibbonEdit(ID_RIBBON_EBTN_5,90,_T("Label:"),1);
- pBtn5->EnableSpinButtons(0,99);
- pBtn5->SetEditText(_T("0"));
- pPanel2->Add(pBtn5);
- CMFCRibbonComboBox*pBtn6=newCMFCRibbonComboBox(ID_RIBBON_EBTN_6,TRUE,74,_T("Label:"),2);
- pBtn6->AddItem(_T("ComboBox"));
- for(i=0;i<20;i++)
- {
- CStringstr;
- str.Format(_T("Item%d"),i+1);
- pBtn6->AddItem(str);
- }
- pBtn6->SelectItem(0);
- pPanel2->Add(pBtn6);
- CMFCRibbonPanel*pPanel3=pCategory->AddPanel(_T("Font"));
- //创建字体选择ComboBox
- CMFCRibbonFontComboBox::m_bDrawUsingFont=TRUE;
- CMFCRibbonFontComboBox*pBtn7=newCMFCRibbonFontComboBox(ID_RIBBON_EBTN_7);
- pBtn7->SelectItem(_T("Arial"));
- pPanel3->Add(pBtn7);