Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Painting of disabled toolbar button
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Painting of disabled toolbar button

 Post Reply Post Reply
Author
Message
akur View Drop Down
Senior Member
Senior Member


Joined: 16 May 2006
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote akur Quote  Post ReplyReply Direct Link To This Post Topic: Painting of disabled toolbar button
    Posted: 16 January 2007 at 2:07am
Hello,

I use the icon in 1st pic in my toolbar button, which - when disabled - was correctly grayed by XTP as on the 2nd pic in v10.1. However, with v10.4, I get a bad look for the same grayed button (see 3rd pic).


(Images are zoomed)

This is how I add this toolbar button (using the same code in both versions v10.1 and v10.4):

    CXTPControlButton *pButton = new CXTPControlButton();
    pButton->SetID( nMyButtonId );
    pButton->SetCustomIcon( hMyIcon );
    pButton->SetStyle(xtpButtonIconAndCaptionBelow);
    m_pToolbar->GetControls()->Add(pButton);
(Disabling of buttons is accomplished by cmd update handlers.)

Where do you think the problem lies? Why is the shadow differently rendered to gray suddenly?

Thank you, in advance!

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 16 January 2007 at 6:25am
Hi,
try to switch these falgs:
 
XTPPaintManager()->GetIconsInfo()->bUseDisabledIcons
XTPPaintManager()->GetIconsInfo()->bOfficeStyleDisabledIcons
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
akur View Drop Down
Senior Member
Senior Member


Joined: 16 May 2006
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote akur Quote  Post ReplyReply Direct Link To This Post Posted: 17 January 2007 at 3:01am
Thank you, it's much better now.
But it's still not the same for some other icons of mine. Eg. from the enabled icon on the left, I get a bad looking disabled icon on the right:

I guess this is because of some transparency handling.

By the way, is there a way to force XTP to use my own versions of disabled, greyed icons? I'm trying to use this code to achieve it:

    UINT nCustomIconId = m_pToolbar->GetImageManager()->AddCustomIcon(CXTPImageManagerIconHandle(hMyIcon));
    CXTPImageManagerIcon* pCustomIconImage = m_pToolbar->GetImageManager()->GetImage(nCustomIconId);
    pCustomIconImage->SetDisabledIcon(CXTPImageManagerIconHandle(hMyIconDisabled));

    CXTPControlButton *pButton = new CXTPControlButton();
    pButton->SetID(nMyId);
    pButton->SetIconId(nCustomIconId);
    pButton->SetStyle(xtpButtonIconAndCaptionBelow);
    m_pToolbar->GetControls()->Add(pButton);


and previously I also set m_pToolbar->GetPaintManager()->GetIconsInfo()->bUseDisabledIcons to use the disabled icons pushed in.

The problem with this is, that XTP makes these greyed icons of mine even more greyed. I mean my rendered, light grey disabled icons (left icon below) become dark grey when drawn by XTP (see right icon below). Could this extra-greying be switched off somehow?



Thank you, in advance!


Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 17 January 2007 at 9:29am

Hi,

 
Don't use AddCustomIcon,
Use standard SetIcons for normal and disabled icons.
For example:
// pCommandBars->GetImageManager()->SetIcons(IDR_MAINFRAME, xtpImageNormal);
// pCommandBars->GetImageManager()->SetIcons(IDR_MAINFRAME, IDR_MAINFRAME_DISABLED, xtpImageDisabled);
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
akur View Drop Down
Senior Member
Senior Member


Joined: 16 May 2006
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote akur Quote  Post ReplyReply Direct Link To This Post Posted: 18 January 2007 at 9:27am
Thank you oleg, but unfortunately this still doesn't work. I've tried the CImageList-based version of SetIcons() (because we don't have fixed, resource-based toolbars), but the disabled images are too dark grey, again.

So finally I ended up with overloading CXTPPaintManager::DrawImage() to execute my own code for drawing disabled buttons. Just for the information of those who may be interested. Anyway, thank you for your help.
Back to Top
wimix View Drop Down
Newbie
Newbie


Joined: 13 March 2007
Location: Germany
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote wimix Quote  Post ReplyReply Direct Link To This Post Posted: 13 March 2007 at 3:33pm
Hi!

I've got a similar problem with disabled icons but I use the standard SetIcons functions.

  m_pDocBar->LoadToolBar(IDR_TOOLBAR_DOC);
  m_pDocBar->SetIconSize(CSize(24,24));
  m_pDocBar->GetImageManager()->SetIcons(IDR_TOOLBAR_DOC, IDB_TOOLBAR_DOC, xtpImageNormal);
  m_pDocBar->GetImageManager()->SetIcons(IDR_TOOLBAR_DOC, IDB_TOOLBAR_DOC_DISABLED, xtpImageDisabled);

The disabled icons are not used.

For testing, I added the disabled icons as hot icons too. They are displayed correctly (=disabled icon) when the mouse is over the buttons.

  m_pDocBar->GetImageManager()->SetIcons(IDR_TOOLBAR_DOC, IDB_TOOLBAR_DOC_DISABLED, xtpImageHot);

Correct enabled icon but wrong disabled icon:

                       

For testing: disabled icon in hot state:

                       


The main window is derived from CXTPFrameWnd. It's embedded as a child window in a Windows Explorer tool bar.

Does somebody have an idea?

Regards


Back to Top
akur View Drop Down
Senior Member
Senior Member


Joined: 16 May 2006
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote akur Quote  Post ReplyReply Direct Link To This Post Posted: 14 March 2007 at 1:22am
Hello,
 
just an idea: did you try to play a little bit with the flags Oleg has told about above? I mean setting/resetting these:
 
XTPPaintManager()->GetIconsInfo()->bUseDisabledIcons
XTPPaintManager()->GetIconsInfo()->bOfficeStyleDisabledIcons
 
Back to Top
wimix View Drop Down
Newbie
Newbie


Joined: 13 March 2007
Location: Germany
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote wimix Quote  Post ReplyReply Direct Link To This Post Posted: 14 March 2007 at 1:03pm
Thank you, akur! Now, it works fine.

I picked the usage of disabled images from the GUI_MsMoney example. It does not set bUseDisabledIcons, so I thought I don't need it too.

Back to Top
akur View Drop Down
Senior Member
Senior Member


Joined: 16 May 2006
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote akur Quote  Post ReplyReply Direct Link To This Post Posted: 15 March 2007 at 3:01am
I'm glad that it helped you.
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.172 seconds.