How to setup toolbars (CMFCToolbar) for small and large icons with different DPI values ?
-
I can create toolbars to support small and large icons with code like this :
{
if (!m_StandardToolBar.CreateEx(this, TBSTYLE_FLAT, style| WS_VISIBLE , CRect(1,1 , 1, 1), ITB_STANDARD_TOOLBAR) )
{
TRACE0("Failed to create toolbar\n");
return false; // fail to create
}CMFCToolBarInfo info; info.m\_uiColdResID = ITB\_STANDARD\_TOOLBAR; info.m\_uiHotResID = ITB\_STANDARD\_TOOLBAR; info.m\_uiLargeColdResID = ITB\_STANDARD\_LARGE\_TOOLBAR; info.m\_uiLargeHotResID = ITB\_STANDARD\_LARGE\_TOOLBAR; m\_StandardToolBar.LoadToolBarEx( ITB\_STANDARD\_TOOLBAR, info , FALSE); m\_StandardToolBar.SetWindowText( CMbString::mbLoadString(IDS\_TOOLBAR\_STANDARD));
}
When changing the "DPI" (what was the "large font/small font) settings before) MFC (Win32) will automagically resize the toolbar bitmaps to fit the new settings. There are now 3 settings : 100% (smaller, default), 125% (medium) and 150% (Larger) If the default small toolbar button is 16x16, then the other sizes will be 20x20 and 24x24 If the default large toolbar button is 32x32, then the other sizez will be 40x40 and 48x48. Now if I have to do this "by the book" I would need to generate toolbars with buttons 16x16, 20x20, 24x24, 32x32, 40x40 and 48x48. so for each toolbar I create I will have something like : // pseudo code
UINT smallToolbarID; if ( DPI == smaller ) { smallToolbarID = 16x16; largeToolbarID = 32x32 } else if ( DPI == medium ) { smallToolbarID = 20x20; largeToolbarID = 40x40 } else if ( DPI == larger) { smallToolbarID = 24x24; largeToolbarID = 48x48 } if (!m\_StandardToolBar.CreateEx(this, TBSTYLE\_FLAT, style| WS\_VISIBLE , CRect(1,1 , 1, 1), ITB\_STANDARD\_TOOLBAR) ) { TRACE0("Failed to create toolbar\\n"); return false; // fail to create } CMFCToolBarInfo info; info.m\_uiColdResID = smallToolbarID; info.m\_uiHotResID = smallToolbarID; info.m\_uiLargeColdResID = largeToolbarID; info.m\_uiLargeHotResID = largeToolbarID; m\_StandardToolBar.LoadToolBarEx( ITB\_STANDARD\_TOOLBAR, info , FALSE); m\_StandardToolBar.SetWindowText( CMbString::mbLoadString(IDS\_TOOLBAR\_STANDARD));
Meaning that for each toolbar, I will have 6 different bitmaps to maintain? Am I thinking this straight or is there a catch somewhere ? Thanks. Max.
I'd rather be phishing!
-
I can create toolbars to support small and large icons with code like this :
{
if (!m_StandardToolBar.CreateEx(this, TBSTYLE_FLAT, style| WS_VISIBLE , CRect(1,1 , 1, 1), ITB_STANDARD_TOOLBAR) )
{
TRACE0("Failed to create toolbar\n");
return false; // fail to create
}CMFCToolBarInfo info; info.m\_uiColdResID = ITB\_STANDARD\_TOOLBAR; info.m\_uiHotResID = ITB\_STANDARD\_TOOLBAR; info.m\_uiLargeColdResID = ITB\_STANDARD\_LARGE\_TOOLBAR; info.m\_uiLargeHotResID = ITB\_STANDARD\_LARGE\_TOOLBAR; m\_StandardToolBar.LoadToolBarEx( ITB\_STANDARD\_TOOLBAR, info , FALSE); m\_StandardToolBar.SetWindowText( CMbString::mbLoadString(IDS\_TOOLBAR\_STANDARD));
}
When changing the "DPI" (what was the "large font/small font) settings before) MFC (Win32) will automagically resize the toolbar bitmaps to fit the new settings. There are now 3 settings : 100% (smaller, default), 125% (medium) and 150% (Larger) If the default small toolbar button is 16x16, then the other sizes will be 20x20 and 24x24 If the default large toolbar button is 32x32, then the other sizez will be 40x40 and 48x48. Now if I have to do this "by the book" I would need to generate toolbars with buttons 16x16, 20x20, 24x24, 32x32, 40x40 and 48x48. so for each toolbar I create I will have something like : // pseudo code
UINT smallToolbarID; if ( DPI == smaller ) { smallToolbarID = 16x16; largeToolbarID = 32x32 } else if ( DPI == medium ) { smallToolbarID = 20x20; largeToolbarID = 40x40 } else if ( DPI == larger) { smallToolbarID = 24x24; largeToolbarID = 48x48 } if (!m\_StandardToolBar.CreateEx(this, TBSTYLE\_FLAT, style| WS\_VISIBLE , CRect(1,1 , 1, 1), ITB\_STANDARD\_TOOLBAR) ) { TRACE0("Failed to create toolbar\\n"); return false; // fail to create } CMFCToolBarInfo info; info.m\_uiColdResID = smallToolbarID; info.m\_uiHotResID = smallToolbarID; info.m\_uiLargeColdResID = largeToolbarID; info.m\_uiLargeHotResID = largeToolbarID; m\_StandardToolBar.LoadToolBarEx( ITB\_STANDARD\_TOOLBAR, info , FALSE); m\_StandardToolBar.SetWindowText( CMbString::mbLoadString(IDS\_TOOLBAR\_STANDARD));
Meaning that for each toolbar, I will have 6 different bitmaps to maintain? Am I thinking this straight or is there a catch somewhere ? Thanks. Max.
I'd rather be phishing!
Hi Did you go with this in the end? Andrew