我用SDI在view区添加了几个对话框,方法是
void CKitView::OnInitialUpdate()
{
CView::OnInitialUpdate();
m_dlg.Create(IDD_FRONT_QC,this);
m_dlg.ShowWindow(SW_SHOW);
}
由于我在view区的左边用的是类outlook形式的,所以对话框不能完全占据wiew区,请问我怎么设置dialog的位置了?
void CKitView::OnInitialUpdate()
{
CView::OnInitialUpdate();
m_dlg.Create(IDD_FRONT_QC,this);
m_dlg.ShowWindow(SW_SHOW);
}
由于我在view区的左边用的是类outlook形式的,所以对话框不能完全占据wiew区,请问我怎么设置dialog的位置了?
解决方案 »
- LINK : fatal error LNK1104: 无法打开文件“winmm.lib”
- 用CreateProcess创建的子进程如何与创建它的父进程通信呢?
- 关于文本框的问题
- 如何通过sql语句修改SQL Server数据库中的指定字段的长度
- DentistryDoctor(牙科医生),我牙疼呀!这2天hook都没搞定。看了你以前的一片帖子,好像就是这样的问题:
- 现在学VC++一年学的好吗?
- tcp层通讯中,阻塞模式和非阻塞模式的区别,请用一段代码说明
- MFC消息循环PeekMessage
- 类的相互调用问题-视窗和对话框传输数据解决方案-Apply按钮的实现?
- Combobox下拉框显示行数怎么修改?
- Windows程序设计提问
- 关于VC的问题
切换视图:
bool CAMComDoc::SwitchToView(CRuntimeClass *pNewViewClass)
{ int row, col;
row=0;col=1;
CMDIFrameWnd* pMainWnd = (CMDIFrameWnd*)AfxGetMainWnd();
// Get the active MDI child window.
CMDIChildWnd* pChild = (CMDIChildWnd*)pMainWnd->MDIGetActive();
// Get the active view attached to the active MDI child window.
CView* pOldActiveView = pChild->GetActiveView();
CSplitterWnd* pSplitter = (CSplitterWnd *)pOldActiveView->GetParent();
// ASSERT(pSplitter->IsChildPane(pOldActiveView, row, col));
pOldActiveView=(CView*)pSplitter->GetPane(row,col);
// If we're already displaying this kind of view, no need to go further.
if (pOldActiveView->IsKindOf(pNewViewClass))
return TRUE;
CRect viewrect;
pOldActiveView->GetWindowRect(&viewrect); // set flag so that document will not be deleted when view is destroyed
m_bAutoDelete = FALSE;
// Delete existing view
CCreateContext context;
context.m_pNewViewClass = pNewViewClass;
context.m_pCurrentDoc = this; pOldActiveView->DestroyWindow(); m_bAutoDelete=TRUE;
// set flag back to default
// Create new view
// POSITION pos=::AfxGetApp()->GetFirstDocTemplatePosition();
context.m_pNewDocTemplate =this->GetDocTemplate();// ::AfxGetApp()->GetNextDocTemplate(pos);
context.m_pLastView = NULL;
// context.m_pCurrentFrame = NULL;
if (!pSplitter->CreateView(row, col, pNewViewClass, viewrect.Size(),
&context))
return FALSE;
CView* pNewView = (CView *)pSplitter->GetPane(row, col);
pNewView->OnInitialUpdate();
// Set active pSplitter->GetParentFrame()->SetActiveView(pNewView);
pSplitter->RecalcLayout();
pNewView->SendMessage(WM_PAINT);
return TRUE;
}
用MoveWindow()或者SetWindowPos()
void CPatchView::OnInitialUpdate()
{
CView::OnInitialUpdate();
CRect rect;
GetClientRect(&rect);
dlgUser.Create(IDD_DLG_USER,this);
dlgUser.ShowWindow(SW_SHOW);
dlgUser.MoveWindow(rect);
dlgLog.Create(IDD_DLG_LOG,this);
dlgLog.ShowWindow(SW_HIDE);
dlgLog.MoveWindow(rect);
}
void CPatchView::SetCurrentView(CString str)
{
if (str.CompareNoCase("日志管理")==0)
{
ASSERT(dlgUser);
ASSERT(dlgLog);
dlgUser.ShowWindow(SW_HIDE);
dlgLog.ShowWindow(SW_SHOW);
}
else
{
ASSERT(dlgUser);
ASSERT(dlgLog);
dlgUser.ShowWindow(SW_SHOW);
dlgLog.ShowWindow(SW_HIDE);
}
}
这是我的代码,可是进入SetCurrentView时候会报错winocc.cpp错误。debug Assertion
我看了一下源码,是dlgUser.ShowWindow(SW_HIDE);报错。请问是什么问题啊?
UINT pageID [] = {IDD_DLG_LOG, IDD_DLG_USER};
CDialog* pDlg;
for (int i = 0; i < 2; i++)
{
switch (i)
{
case 0:
pDlg = new CDlgUser();
break;
case 1:
pDlg = new CDlgLog();
break;
default:
ASSERT (FALSE);
}
pDlg->Create (pageID[i], this);
pDlg->ModifyStyle (WS_CAPTION|WS_BORDER, 0);
m_arrayForms.Add (pDlg); CRect rect;
GetClientRect(&rect);
pDlg->MoveWindow(rect); }
m_pActivePage = m_arrayForms [0];
m_pActivePage->ShowWindow (SW_SHOW);
可是在pDlg->Create (pageID[i], this);这句话报错
void CPatchView::OnInitialUpdate()
{
CView::OnInitialUpdate(); UINT pageID [] = {IDD_DLG_USER,IDD_DLG_LOG};
CDialog* pDlg; for (int i = 0; i < 2; i++)
{
switch (i)
{
case 0:
pDlg = new CDlgUser();
break;
case 1:
pDlg = new CDlgLog();
break;
default:
ASSERT (FALSE);
}
ASSERT(pageID[i]);
pDlg->Create (pageID[i], this);
pDlg->ModifyStyle (WS_CAPTION|WS_BORDER, 0);
m_arrayForms.Add (pDlg); CRect rect;
GetClientRect(&rect);
pDlg->MoveWindow(rect); }
m_pActivePage = m_arrayForms [0];
m_pActivePage->ShowWindow (SW_SHOW);
}
}void CPatchView::SetCurrentView(UINT m_uiCurrView)
{ UINT uiPage;
CDialog* pPage =NULL;
pPage = m_arrayForms [m_uiCurrView];
ASSERT (pPage != NULL);
ASSERT (m_pActivePage != NULL); if (pPage != m_pActivePage)
{
m_pActivePage->ShowWindow (SW_HIDE);
pPage->ShowWindow (SW_SHOW);
m_pActivePage = pPage;
}
m_nActivePage = uiPage;
}
目前可以显示,但是调用SetCurrentView时候,执行到
pPage = m_arrayForms [m_uiCurrView];时。就报错了afxtempl.cppd的262行debug assertion。请大家帮我分析一下啊。谢谢