void CContainerUI::SetHWND(HWND hWnd, CPaintManagerUI* mgr) { m_pManager = mgr; for(int c = GetCount(), i=0; i<c; ++i){ CControlUI* pControl = static_cast<CControlUI*>(m_items[i]); HWND hChild = NULL; // 这里所谓的 "容器" 只是一个虚拟的窗口, 它本身并不具有窗口句柄 // VC6.0的RTTI在VS12中使用时无效, 不能用typeid来判断 if(_tcscmp(pControl->GetClass(), CControlUI::GetClassStatic()) == 0){ int id = pControl->GetID(); if(id == -1) hChild = NULL; else{ hChild = GetDlgItem(hWnd, id); assert(hChild != NULL); } } else{ hChild = hWnd; } pControl->SetHWND(hChild, mgr); } }