Kieveli
Kieveli

Reputation: 11084

How can you make buttons on a MSVS C++ CToolBar larger along with their images?

We have a touch screen, and the toolbar is too small to hit with my meaty fingers. Is there an easy way I can have an option to make the toolbar buttons bigger and easier to hit?

So far I've attempted a few things:

m_toolbar.SetSizes( CSize(64,64), CSize(50,50) );
m_toolbar.SetSizes( CSize(64,64), CSize(50,50) );
m_toolbar.GetToolBarCtrl().SetButtonWidth( 64, 64 );
m_toolbar.GetToolBarCtrl().SetButtonSize( CSize(64, 64) );

None of these approaches stretches the images as well. The buttons get larger, and are fully functional, but the images do not overlap the buttons the way they normally would. I would prefer to keep a single image list for the icons, and have the images stretched to fit.

Upvotes: 1

Views: 1706

Answers (2)

Javier De Pedro
Javier De Pedro

Reputation: 2239

As far as I know there is no way to make images resize with the size of the buttons. MFC applications use bmp and not vectorial images.

So you will have to supply a bmp images with the disired sizes.

You can use a CImageList and SetImageList to set the images but then you will have to
initialize images there with the disired size also.

Upvotes: 1

Serge Wautier
Serge Wautier

Reputation: 21898

At toolbar creation time, create an empty CImageList with size 64x64 (let's call it large). Load the original image list from resources (we call it small).

Iterate over each image in small and copy/resize it to large. Then assign large to your toolbar. Somewhat cumbersome bui should work.

HTH,

Upvotes: 1

Related Questions