示例#1
0
//+====================================================================================
//
// Method:EnsureDispNode
//
// Synopsis: Creates a DispItemPlus suitable for 'Adornment'
//
//------------------------------------------------------------------------------------
void CAdorner::EnsureDispNode()
{
    Assert(_pElement);
    Assert(_pView);
    Assert(_pView->IsInState(CView::VS_OPEN));

    CTreeNode* pTreeNode = _pElement->GetFirstBranch();

	if(!_pDispNode && pTreeNode)
	{
		_pDispNode = (CDispNode*)CDispRoot::CreateDispItemPlus(this,
			TRUE,
			FALSE,
			FALSE,
			DISPNODEBORDER_NONE,
			FALSE);

        if(_pDispNode)
        {
            _pDispNode->SetExtraCookie(GetDispCookie());
            _pDispNode->SetLayerType(GetDispLayer());
            _pDispNode->SetOwned(TRUE);
        }
    }

    if(_pDispNode && !_pDispNode->GetParentNode())
    {
        CNotification nf;

        nf.ElementAddAdorner(_pElement);
        nf.SetData((void*)this);

        _pElement->SendNotification(&nf);
    }
}