CTreeControl调用SetWindowPos出现断言咋回事
CTreeControl调用SetWindowPos出现断言怎么回事
在VS2008中添加了Tree Control控件,并添加了控制变量CTreeCtrl m_treeKaodian;
在OnSize函数中
触发断言
BOOL CWnd::SetWindowPos(const CWnd* pWndInsertAfter, int x, int y, int cx,
int cy, UINT nFlags)
{
ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));
检查发现m_pCtrlSite 为NULL
哪位知道怎么回事。
------解决方案--------------------
这是UI最基本的了 onsize要首先判断hwnd的有效性
------解决方案--------------------
onsize 有 cx=0 的 情况, 那时m_treeKaodian 还没有创建。
在VS2008中添加了Tree Control控件,并添加了控制变量CTreeCtrl m_treeKaodian;
在OnSize函数中
void CxxDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
CRect rtDlg;
GetClientRect(&rtDlg);
if (rtDlg.Width()<50)
{
return;
}
int nWidth,nHight;
nWidth = (rtDlg.Width()-50)/2;
nHight = rtDlg.Height()-50;
m_treeKaodian.SetWindowPos(NULL,20,20,20+nWidth,20+nHight,0);
}
触发断言
BOOL CWnd::SetWindowPos(const CWnd* pWndInsertAfter, int x, int y, int cx,
int cy, UINT nFlags)
{
ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));
检查发现m_pCtrlSite 为NULL
哪位知道怎么回事。
------解决方案--------------------
这是UI最基本的了 onsize要首先判断hwnd的有效性
------解决方案--------------------
onsize 有 cx=0 的 情况, 那时m_treeKaodian 还没有创建。