分割视图
//分割(插入->资源->IDD_FORMVIEW,建立类向导基类选择CFormView)
//在MainFrm.h中定义
CSplitterWnd m_splitter;
//通过类向导添加函数OnCreateClient(),添加代码
m_splitter.CreateStatic(this,1,2);
m_splitter.CreateView(0,0,RUNTIME_CLASS(FormDlg),CSize(400,100),pContext);
m_splitter.CreateView(0,1,RUNTIME_CLASS(CFGView),CSize(200,100),pContext);
return true;
//对话框中计算器功能实现(类向导添加函数Add())
void FormDlg::OnAdd()
{
// TODO: Add your control notification handler code here
UpdateData();
m_num3=m_num1+m_num2;
UpdateData(false);
}
//对话框中添加按钮,实现消息左右交互
//视图类头文件中
CString strtext;
int x;
bool playflag;
void Play();
//构造函数中初始化
x=0;
playflag=false;
void FormDlg::OnPlay() //类向导添加按钮消息函数
{
// TODO: Add your control notification handler code here
CMainFrame *pframe=(CMainFrame *)AfxGetApp()->m_pMainWnd;
CFGView *pView=(CFGView *)pframe->m_splitter.GetPane(0,1);
CString strt;
GetDlgItem(IDC_EDIT3)->GetWindowText(strt);
pView->strtext=strt;
pView->Play();
}
void CFGView::Play() //自定义函数
{
playflag=!playflag;
if(playflag)
SetTimer(1,100,NULL);
else
KillTimer(1);
}
//视图类中添加类向导WM_TIMER,添加代码
Invalidate();
//视图类源文件OnDraw()函数中添加代码
CRect rect;
GetClientRect(&rect);
x=x+3;
if(x>rect.right)
{
x=0;
}
CString strs,xs;
strs.Format(\"x=%d,%s\
pDC->TextOut(x,200,strs);
//右左交互,视图类源文件OnDraw()中添加代码
CMainFrame *pframe=(CMainFrame *)AfxGetApp()->m_pMainWnd;
CEdit *p1=(CEdit *)pframe->m_splitter.GetPane(0,0)->GetDlgItem(IDC_EDIT4);
xs.Format(\"x=%d\
p1->SetWindowText (xs);
//下右交互(对话条:插入资源->Dialog(展开)->选IDD_DIALOGBAR->新建)
//主框架头文件中
CDialogBar mydlg;
//主框架源文件OnCreate函数中
mydlg.Create(this,IDD_DIALOGBAR,CBRS_BOTTOM,IDD_DIALOGBAR);
因篇幅问题不能全部显示,请点此查看更多更全内容