Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Disabled image list Collapse All
Subject Author Date
Paula Burkle Mar 12, 2004 - 10:52 AM

how can I set the disabled image list using CExtToolControlBar?


thanks, Paula.



Technical Support Mar 13, 2004 - 9:49 AM

Dear Paula,

The toolbar window owns a list of its button objects which are instances of the CExtBarButton class or classes derived from it. Each button keeps only the corresponding command identifier and requests the global command manager object for the command icon. The command manager keeps only one icon for each command. Disabled icons are painted automatically by the global paint manager depending on the currently used UI theme. So, the toolbar does not contain any images at all.

Of course, it is possible to implement toolbar buttons each of which will contain more than one image. You may see how it is done in the FunnyBars sample application.

And, of course, we can help you code such toolbar if you need.

Paula Burkle Mar 17, 2004 - 1:54 PM

Hi,

I created a class derived from CExtBarButton and overrided the method GetIconPtr(). When the button is disabled, I return my own CExtCmdIcon. It seems like FunnyBars sample. The problem is: the disabled imagem is not appearing. Here are some passages from my code:

BOOL CMyToolControlBar::SetDisabledImageList( UINT nBitmapID )
{
BOOL rtn;

CExtBarButton * pBarButton = GetButton( 0 );
ASSERT( pBarButton );

CExtCmdIcon * pIcon = pBarButton->GetIconPtr();
ASSERT( pIcon );

CSize size = pIcon->GetSize();

rtn = m_bitmap.LoadBitmap( nBitmapID );
rtn &= m_imageList.Create( size.cx, size.cy, ILC_COLORDDB|ILC_MASK, 13, 1 );
m_imageList.Add( &m_bitmap, RGB(192,192,192) );

return rtn;
}

CExtCmdIcon * CMyToolButton::GetIconPtr()
{
CExtCmdIcon * pIcon = CExtBarButton::GetIconPtr();

if ( !IsDisabled() )
return pIcon;

if ( m_iconDisabled.IsEmpty() )
{
CMyToolControlBar * pToolCtrlBar = ( CMyToolControlBar * ) GetBar();
COLORREF clrTransparent = pIcon->GetBitmapTransparentColor();
CRect rect( CPoint( 0, 0 ), pIcon->GetSize() );

ASSERT( pIcon->IsBitmapBased() );

m_iconDisabled.AssignFromHBITMAP(
pToolCtrlBar->GetDisabledBitmap( m_nButtonCmdID ),RGB(192,192,192), rect );

ASSERT( !m_iconDisabled.IsEmpty() );
}
return &m_iconDisabled;
}

best regards,
Paula.

Technical Support Mar 18, 2004 - 12:02 PM

Dear Paula,


Your code is correct. But you also need to override the CExtBarButton::Paint() virtual method in your button class. First, please just copy the body of the CExtBarButton::Paint() method into your CMyToolButton::Paint() method as is. Then please take a look at the invoking of the CExtPaintManager::PAINTPUSHBUTTONDATA _ppbd(...) constructor:

CExtPaintManager::PAINTPUSHBUTTONDATA _ppbd(
  this,
  bHorz,
  rcArea,
  sText,
  pIcon,
  true,
  bHover,
  bPushed,
  bIndeterminate,
  bEnabled, /// <<< --- change to true
  true,false,false,
. . .

Please replace the first bEnabled entry with true. This will "tell" the paint manager not to use the disabled effect when painting the button’s icon.