VS 2008 分割窗体视图断言错误

chentao1206 2014-02-12 04:21:15
VC6.0的项目,迁移到VS2008上,创建窗体分割视图时,出现断言错误!VC6.0上能正常运行,没有问题
大家帮忙看下是啥问题,谢谢了
/////////////////////////////////////////////////////////////////////////////
// CSplitterWnd default creation of parts

// You must create ALL panes unless DYNAMIC_SPLIT is defined!
// Usually the splitter window is invisible when creating a pane
BOOL CSplitterWnd::CreateView(int row, int col,
CRuntimeClass* pViewClass, SIZE sizeInit, CCreateContext* pContext)
{
#ifdef _DEBUG
ASSERT_VALID(this);
ASSERT(row >= 0 && row < m_nRows);
ASSERT(col >= 0 && col < m_nCols);
ASSERT(pViewClass != NULL);
ASSERT(pViewClass->IsDerivedFrom(RUNTIME_CLASS(CWnd)));
ASSERT(AfxIsValidAddress(pViewClass, sizeof(CRuntimeClass), FALSE));

if (GetDlgItem(IdFromRowCol(row, col)) != NULL)
{
TRACE(traceAppMsg, 0, "Error: CreateView - pane already exists for row %d, col %d.\n",
row, col);
ASSERT(FALSE);
return FALSE;
}
#endif

// set the initial size for that pane
m_pColInfo[col].nIdealSize = sizeInit.cx;
m_pRowInfo[row].nIdealSize = sizeInit.cy;

BOOL bSendInitialUpdate = FALSE;

CCreateContext contextT;
if (pContext == NULL)
{
// if no context specified, generate one from the currently selected
// client if possible
CView* pOldView = (CView*)GetActivePane();
if (pOldView != NULL && pOldView->IsKindOf(RUNTIME_CLASS(CView)))
{
// set info about last pane
ASSERT(contextT.m_pCurrentFrame == NULL);
contextT.m_pLastView = pOldView;
contextT.m_pCurrentDoc = pOldView->GetDocument();
if (contextT.m_pCurrentDoc != NULL)
contextT.m_pNewDocTemplate =
contextT.m_pCurrentDoc->GetDocTemplate();
}
pContext = &contextT;
bSendInitialUpdate = TRUE;
}

CWnd* pWnd;
TRY
{
pWnd = (CWnd*)pViewClass->CreateObject(); //此处断言错误
if (pWnd == NULL)
AfxThrowMemoryException();
}
CATCH_ALL(e)
{
TRACE(traceAppMsg, 0, "Out of memory creating a splitter pane.\n");
// Note: DELETE_EXCEPTION(e) not required
return FALSE;
}
END_CATCH_ALL

ASSERT_KINDOF(CWnd, pWnd);
ASSERT(pWnd->m_hWnd == NULL); // not yet created

DWORD dwStyle = AFX_WS_DEFAULT_VIEW & ~WS_BORDER;

// Create with the right size (wrong position)
CRect rect(CPoint(0,0), sizeInit);
if (!pWnd->Create(NULL, NULL, dwStyle,
rect, this, IdFromRowCol(row, col), pContext))
{
TRACE(traceAppMsg, 0, "Warning: couldn't create client pane for splitter.\n");
// pWnd will be cleaned up by PostNcDestroy
return FALSE;
}
ASSERT((int)_AfxGetDlgCtrlID(pWnd->m_hWnd) == IdFromRowCol(row, col));

// send initial notification message
if (bSendInitialUpdate)
pWnd->SendMessage(WM_INITIALUPDATE);

return TRUE;
}
...全文
139 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
chentao1206 2014-02-17
  • 打赏
  • 举报
回复
已经解决了!SystemParametersInfo ( SPI_GETNONCLIENTMETRICS... 在VC 2008 里不能正常工作 NONCLIENTMETRICS ncms = {0} ; ncms.cbSize = sizeof(NONCLIENTMETRICS); int s = sizeof(NONCLIENTMETRICS); BOOL b = SystemParametersInfo (SPI_GETNONCLIENTMETRICS, (int)&s, &ncms, 0); DWORD dw = GetLastError(); 上面这段代码在VC 6.0 中工作正常,但是在VC 2008 里 SystemParametersInfo 返回 0,而 GetLastError 返回的却是 0 简单订正如下: ncms.cbSize = sizeof(NONCLIENTMETRICS) - sizeof(ncms.iPaddedBorderWidth); 实际是由于从 Vista 和 Windows Server 2008 开始 NONCLIENTMETRICS 在最后增加了iPaddedBorderWidth字段,如果你的程序打算同时支持 vista 或 XP ,Windows 2000, Windows Server 2003,那么应该先调用 GetVersionEx 检测Windows版本,然后决定是否需要减去 sizeof (ncms.iPaddedBorderWidth) ; 大家可以参考下这http://blog.csdn.net/qsycn/article/details/4790059
赵4老师 2014-02-13
  • 打赏
  • 举报
回复
崩溃的时候在弹出的对话框按相应按钮进入调试,按Alt+7键查看Call Stack里面从上到下列出的对应从里层到外层的函数调用历史。双击某一行可将光标定位到此次调用的源代码或汇编指令处。

64,650

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧