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 Tech Support » I want to draw a non-activity button in NcArea of ControlBar. Collapse All
Subject Author Date
tera tera Feb 7, 2010 - 11:17 PM

Hello.


I want to draw a non-activity button in NcArea of ControlBar.

Please teach a command to draw a non-activity button.




Is there a command drawing the non-activity in CExtBitmap?


Technical Support Feb 8, 2010 - 12:48 PM

Your screen shot demonstrates the undo and redo buttons inserted into the quick access toolbar of the ribbon bar. The undo button is enabled and the redo button is disabled. The ribbon buttons are working exactly like toolbar buttons. If you need to disable some button, then you should add the command updating method for it and use the <code>CCmdUI::Enable()<code> method to disable the command.

tera tera Feb 8, 2010 - 6:35 PM

 


In NcArea of CExtContorlBar, I draw a button in bitmap.

Therefore I cannot use the CCmdUI command.

I want to draw BitMap for a non-activity image.

Please teach a good command.


// ---------------------------------------------------------------------------- /**  *  @brief    */ // ---------------------------------------------------------------------------- CMuBarNcAreaButton::CMuBarNcAreaButton(  CExtControlBar * pBar,  UINT uID,  UINT uIDB,  CString csStr  )  : CExtBarNcAreaButton( pBar ) {  m_uID  = uID;  m_iBitmap = 0;

 if ( uIDB >= 0 ){   PCExtBitmap pBitmap( new CExtBitmap );   pBitmap->LoadBMP_Resource( MAKEINTRESOURCE(uIDB) ); pBitmap->Make32(); pBitmap->AlphaColor( RGB(255,0,255), RGB(0,0,0), 0 );   m_caBitmap.Add( pBitmap );  }  m_csStr = csStr; }

// ---------------------------------------------------------------------------- /**  *  @brief    */ // ---------------------------------------------------------------------------- void CMuBarNcAreaButton::OnNcAreaDraw( CDC & dc ) {  ASSERT_VALID( this );  ASSERT( dc.GetSafeHdc() != NULL );  ASSERT( OnQueryVisibility() );  if( m_rc.IsRectEmpty() )   return;

 CExtControlBar * pBar = GetBar();  if( pBar->NcButtons_HandleDraw(    dc,    this,    pBar,    NULL    )   ){   return;  }

 m_bDisabled = true;  CWnd * pWnd = GetBar()->GetWindow(GW_CHILD);  if( pWnd != NULL )  {   m_bDisabled = false;  }

 if ( m_iBitmap >= 0 ){   // Bitmap表示   CExtBitmap *pBitmap;   pBitmap = SMART(m_caBitmap.GetAt(m_iBitmap));   NcDrawBitMap(    dc ,    pBitmap   );  }else{   if ( m_iPanitManagerDraw >= 0 ){    // PaintManager表示    NcDrawDefault( dc, m_iPanitManagerDraw    );   }else{    NcDrawDefault( dc, CExtPaintManager::__DCBT_EMPTY    );   }  } }

// ---------------------------------------------------------------------------- /**  *  @brief   非クライアント領域にビットマップを描画する  *  @param   dc [in]  */ // ---------------------------------------------------------------------------- void CMuBarNcAreaButton::NcDrawBitMap(  CDC & dc ,  CExtBitmap * pBitmap  ) {  int nDockBtnGlyptT=0;

 ASSERT_VALID( this );  ASSERT( dc.GetSafeHdc() != NULL );  ASSERT( OnQueryVisibility() );  if( m_rc.IsRectEmpty() )   return;  bool bMenuTracking =   CExtPopupMenuWnd::IsMenuTracking() ? true : false;  bool bDrawActive = false;

#if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)  if( !IsBarAutoHideMode( NULL, &bDrawActive ) ) #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)   bDrawActive = IsBarWndActive();  if( GetBar()->IsKindOf(RUNTIME_CLASS(CExtToolControlBar)) )   bDrawActive = false;

 CExtPaintManager::PAINTDOCKINGCAPTIONBUTTONDATA _pdcbd(   this,   m_rc,   (CExtPaintManager::e_docking_caption_button_t)nDockBtnGlyptT,   (!m_bDisabled) && m_bHover && (!bMenuTracking) && (!m_bPaintingCombinedArea),   (!m_bDisabled) && m_bPushed && (!bMenuTracking) && (!m_bPaintingCombinedArea),   (!m_bDisabled),   (!IsBarFixedMode()) || m_bPaintingCombinedArea,   bDrawActive,   IsBarFloated()   );

 CRect rcGlyph( _pdcbd.m_rcClient );  rcGlyph.NormalizeRect();

 //-----------------------------------------------------------------------  // 選択情報描画  if(  (_pdcbd.m_bHover || _pdcbd.m_bPushed)   && _pdcbd.m_bEnabled   )  {

  dc.FillSolidRect(    &rcGlyph,    //clr3dHilight    g_PaintManager->GetColor( _pdcbd.m_bPushed  ? CExtPaintManagerXP::XPCLR_HILIGHT  : CExtPaintManagerXP::CLR_3DFACE_IN  , _pdcbd.m_pHelperSrc, _pdcbd.m_lParam )    );   CRect rcBtnBorder(rcGlyph);   rcBtnBorder.InflateRect(1,1);   COLORREF clrBtnBorder =    g_PaintManager->GetColor( _pdcbd.m_bBarWndActive  ? CExtPaintManagerXP::XPCLR_HILIGHT  : CExtPaintManagerXP::XPCLR_HILIGHT_BORDER  , _pdcbd.m_pHelperSrc, _pdcbd.m_lParam );   dc.Draw3dRect(    rcBtnBorder,    clrBtnBorder,    clrBtnBorder    );  }

 pBitmap->AlphaBlend( dc.GetSafeHdc() , m_rc );

}

Technical Support Feb 9, 2010 - 7:46 AM

You are using the code like this:

CExtBitmap * pBitmap = . . .
pBitmap->AlphaBlend( dc.GetSafeHdc() , m_rc );

But you can switch using the CExtCmdIcon-based code like this.
CExtBitmap * pBitmap = . . .
CExtCmdIcon _icon;
_icon.m_bmpNormal = *pBitmap;
CExtCmdIcon::e_paint_type_t ePT = CExtCmdIcon::__PAINT_NORMAL;
_icon.Paint( g_PaintManger.GetPM(), dc.GetSafeHdc() , m_rc, ePT );

The icon supports the disabled state painting based on the currently installed paint manager. You should use the CExtCmdIcon::__PAINT_DISABLED constant.