To eliminate unnecessary repainting whenever the user changes the selected object, only the old and the new selected objects need to be invalidated. This results in smarter repainting than simply invalidating the entire client area of the view.
To add update hints to selection code
SetSelection
member function in CContainerView
and replace the following code:Invalidate();
m_pSelection = pItem;
with this code:
// update view to new selection
if (m_pSelection != pItem)
{
if (m_pSelection != NULL)
OnUpdate(NULL, HINT_UPDATE_ITEM, m_pSelection);
m_pSelection = pItem;
if (m_pSelection != NULL)
OnUpdate(NULL, HINT_UPDATE_ITEM, m_pSelection);
}