I have several large toolbars in an MFC application for Window 8.1. Right now I am using the following code to replace the image of each button using current DPI scaling when the application is moved to a monitor with different DPI settings.
const auto& toolbars = m_cToolBarManager.GetToolbar();
for (const auto& toolbar : toolbars)
{
CMFCToolBarImages* images = toolbar->GetImages();
for (int index = 0; index < toolbar->GetCount(); ++index)
{
CMFCToolBarButton* button = (CMFCToolBarButton*)toolbar->GetButton(index);
TRY_POINTER(button);
if (button->m_nStyle & TBBS_SEPARATOR)
{
continue;
}
images->AddIcon(LoadScaledIcon(button->m_nID));
}
}
Each time the application is moved to a different monitor hundreds of images have to be loaded and set for the buttons. Moreover, due to a large number of images embedded as resources, the application executable becomes larger.
Is there more efficient way to do this?