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 » SetTextColor for GroupBox Collapse All
Subject Author Date
lester oidka Jun 30, 2006 - 12:16 PM

SetTextColor doesn’t work correctly for me - it doesn’t chage the caption’s color. The styles works fine - I’d like to know how to set caption color of all group boxes in my app to have the same style (FLAT STYLE, black Caption color).

this is code that doesn’t work for me     

m_cUsrGB.SetTextColor(RGB (100,10,0), true); - doesn`t work
m_cUsrGB.SetStyle(CExtGroupBox::e_style_t::STYLE_FLAT); - works fine

I use latest prof-uis

Technical Support Jul 3, 2006 - 10:53 AM

Thank you for reporting the bug. Here is the bug fix. Please update the following two methods and recompile the library.

ExtGroupBox.cpp file:

COLORREF CExtGroupBox::OnQueryTextColor(
 bool bEnabled // = true
 ) const
{
 ASSERT_VALID( this );
 COLORREF clrText = GetTextColor( bEnabled );
 return clrText;
}
ExtPaintManager.cpp file:
bool CExtPaintManager::PaintGroupBoxLabel(
 CDC & dc,
 __EXT_MFC_SAFE_LPCTSTR strText,
 COLORREF clrText,
 HFONT hFont,
 DWORD dwDrawTextFlags,
 bool bEnabled,
 const RECT & rcText,
 CObject * pHelperSrc,
 LPARAM lParam // = 0L
 )
{
 ASSERT_VALID( this );
 ASSERT( dc.GetSafeHdc() != NULL );
 lParam;
 
CWnd * pWnd =
  DYNAMIC_DOWNCAST(
   CWnd,
   pHelperSrc
   );
 ASSERT( pWnd != NULL );
 ASSERT_VALID( pWnd );
 
HGDIOBJ hOldFont = NULL;
 if( hFont != NULL )
  hOldFont = ::SelectObject( dc, (HGDIOBJ)hFont );
INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
 
 if(  (! g_PaintManager.m_UxTheme.IsControlsThemed()) 
  || clrText != COLORREF(-1L)
  )
 {
  if( clrText == COLORREF(-1L) )
  {
   clrText =
    QueryObjectTextColor(
     dc,
     bEnabled,
     false,
     false,
     false,
     pHelperSrc
     );
   if( clrText == COLORREF(-1L) )
    clrText =
     GetColor(
      bEnabled
       ? COLOR_BTNTEXT
       : COLOR_3DSHADOW,
      pHelperSrc
      );
  }  
  COLORREF clrOldText = dc.SetTextColor( clrText );
  CRect rc( rcText );
  dc.DrawText(
   LPCTSTR(strText),
   int(_tcslen(strText)),
   rc,
   dwDrawTextFlags
   );
  dc.SetTextColor( clrOldText );
 } // if( ! g_PaintManager.m_UxTheme.IsControlsThemed() )
 else
 {
  if( g_PaintManager.m_UxTheme.OpenThemeData( 
    pWnd->GetSafeHwnd(), 
    L"BUTTON" 
    ) != NULL
   )
  {
   VERIFY( 
    g_PaintManager.m_UxTheme.DrawThemeText(
     dc.GetSafeHdc(), 
     BP_GROUPBOX, 
     bEnabled 
      ? GBS_NORMAL 
      : GBS_DISABLED, 
     LPCTSTR(strText),
     -1,
     dwDrawTextFlags,
     NULL,
     &rcText
     ) == S_OK
    );
   g_PaintManager.m_UxTheme.CloseThemeData();
  }
 } // else from if( ! g_PaintManager.m_UxTheme.IsControlsThemed() )
 
 dc.SetBkMode( nOldBkMode );
 if( hOldFont != NULL )
  ::SelectObject( dc, hOldFont );
 
 return false;
}