Print Page | Close Window

Painting of disabled toolbar button

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=6130
Printed Date: 27 September 2024 at 7:43am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Painting of disabled toolbar button
Posted By: akur
Subject: Painting of disabled toolbar button
Date 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!




Replies:
Posted By: Oleg
Date 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


Posted By: akur
Date 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!




Posted By: Oleg
Date 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


Posted By: akur
Date 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.


Posted By: wimix
Date 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




Posted By: akur
Date 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
 


Posted By: wimix
Date 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.



Posted By: akur
Date Posted: 15 March 2007 at 3:01am
I'm glad that it helped you.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net