Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Have same button with different size in a ribbon
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Have same button with different size in a ribbon

 Post Reply Post Reply
Author
Message
fleg View Drop Down
Groupie
Groupie


Joined: 11 July 2012
Status: Offline
Points: 45
Post Options Post Options   Thanks (0) Thanks(0)   Quote fleg Quote  Post ReplyReply Direct Link To This Post Topic: Have same button with different size in a ribbon
    Posted: 01 June 2017 at 11:22am
Hi,

In a RibbonBar I'm doing the following.
In 2 different tabs, I'm adding a button with the same ID,
on the first tab, I want to have a large button (32x32)

pCXTPRibbonGroup->Add(xtpControlButton, verifyID(ID_ACTION))->SetIconSize(CSize(32, 32));

and have a small button on the second tab (16x16).

pCXTPRibbonGroup->Add(xtpControlButton, verifyID(ID_ACTION))->SetIconSize(CSize(16, 16));

Before creating button, I assign Icon to action ID  calling XTPImageManager()::SetIcons(), once for 32x32 once for 16x16.

Problem is both buttons appear big (32x32), so SetIconSize() seems to have no effect on my case.

Workaround is to have 2 separated ID, like ID_ACTION_16, ID_ACTION_32
But It makes code more complicated and might cause some errors.

any method better than CXTPControl::SetIconSize()
could be used for that ?

Thanks,

Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 01 June 2017 at 1:34pm
Hello fleg,

You can get desirable behavior by using SetStyle() method.
By default used xtpButtonAutomatic  style. With xtpButtonAutomatic size of ribbon buttons depend on existing free space. And can be changed from big to small with resizing of window.

With xtpButtonIconAndCaption and xtpButtonIcon  the icon always will be small. Except you set some big size  pControl->SetIconSize(CSize(32, 32));

Regards,
 Oleksandr Lebed
Back to Top
fleg View Drop Down
Groupie
Groupie


Joined: 11 July 2012
Status: Offline
Points: 45
Post Options Post Options   Thanks (0) Thanks(0)   Quote fleg Quote  Post ReplyReply Direct Link To This Post Posted: 02 June 2017 at 2:44am
Hi Oleksandr,

This is working perfectly.
Might be nice to have mention in documentation of GetSize() to indicate this strick about the button style.

Many thanks for the help.

Fabien
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.219 seconds.