在Dialog中嵌入View的方法
2008-08-29 14:28
253 查看
在dialog中嵌入view也没有想象到的那么复杂,遵循如下步骤即可。
1. Create 一个 child类型的CFrameWnd,摆正位置。
2. 正确设置CCreateContext
3. Create 出View与CFrameWnd关联4. Show it!
看代码:
CWnd* pPosWnd = GetDlgItem(IDC_VIEW_POSITON);
CRect rect;
pPosWnd->GetWindowRect(&rect);
CRect rectView = rect;
ScreenToClient(&rect);
m_pFrame = new CFrameWnd();
m_pFrame->Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rect, this);
m_pFrame->ScreenToClient(&rectView);
m_pDoc = static_cast<CDlgViewDoc*>(RUNTIME_CLASS(CDlgViewDoc)->CreateObject());
CCreateContext context;
context.m_pNewViewClass = RUNTIME_CLASS(CDlgViewView);
context.m_pCurrentDoc = m_pDoc;
context.m_pNewDocTemplate = NULL;
context.m_pLastView = NULL;
context.m_pCurrentFrame = m_pFrame;
CView* pView = static_cast<CView*>(RUNTIME_CLASS(CDlgViewView)->CreateObject() );
if( !pView )
return FALSE;
if( !pView->Create(NULL,NULL,AFX_WS_DEFAULT_VIEW, rectView, m_pFrame, AFX_IDW_PANE_FIRST,&context) )
return FALSE;
pView->ShowWindow(SW_SHOW);
pView->OnInitialUpdate();
1. Create 一个 child类型的CFrameWnd,摆正位置。
2. 正确设置CCreateContext
3. Create 出View与CFrameWnd关联4. Show it!
看代码:
CWnd* pPosWnd = GetDlgItem(IDC_VIEW_POSITON);
CRect rect;
pPosWnd->GetWindowRect(&rect);
CRect rectView = rect;
ScreenToClient(&rect);
m_pFrame = new CFrameWnd();
m_pFrame->Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rect, this);
m_pFrame->ScreenToClient(&rectView);
m_pDoc = static_cast<CDlgViewDoc*>(RUNTIME_CLASS(CDlgViewDoc)->CreateObject());
CCreateContext context;
context.m_pNewViewClass = RUNTIME_CLASS(CDlgViewView);
context.m_pCurrentDoc = m_pDoc;
context.m_pNewDocTemplate = NULL;
context.m_pLastView = NULL;
context.m_pCurrentFrame = m_pFrame;
CView* pView = static_cast<CView*>(RUNTIME_CLASS(CDlgViewView)->CreateObject() );
if( !pView )
return FALSE;
if( !pView->Create(NULL,NULL,AFX_WS_DEFAULT_VIEW, rectView, m_pFrame, AFX_IDW_PANE_FIRST,&context) )
return FALSE;
pView->ShowWindow(SW_SHOW);
pView->OnInitialUpdate();
相关文章推荐
- 在Dialog中嵌入View的方法
- 在Dialog中嵌入View的方法
- 在Dialog中嵌入View的方法
- QTableView中嵌入复选框CheckBox方法:实现QAbstractItemDelegate的paint()函数。
- 《转载》Android AlertDialog 方法setView(view,0,0,0,0)的使用
- QTableView中嵌入复选框CheckBox 的四种方法总结
- art.Dialog.open:IE6/IE7/IE8下无法打开嵌入页面的解决方法
- ScrollView嵌入ViewPager 滑动冲突的解决方法
- 【Qt】QTableView中嵌入复选框CheckBox 的四种方法总结
- SThtmlDialog例子,MFC嵌入HTML控件的方法
- 在View类里嵌入CEdit控件的方法。
- QTableView中嵌入CheckBox的四种方法
- DatePicker和DataPickerDialog以及AutoCompleteTextView的基本使用方法
- Android AlertDialog 方法setView(view,0,0,0,0)开发自定义对话框
- XIB或者storyboard中嵌入自定义view(xib)的方法
- listview嵌入scrolview冲突解决方法
- asp.net Mvc中实现在View页面中嵌入公用动态数据,实现方法为:include(包含动态页面数据)
- python QQTableView中嵌入复选框CheckBox四种方法
- 把dialog嵌入到FormView的注意事项
- 将网页嵌入到dialog中的方法