I'd like to have a function to get theme colors, in particular the colors used in tables.
Without themes, it was easy to get the relevant colors with GetSysColor:
Code: Select all
COLORREF MTBLSUBCLASS::GetDefaultColorNoTheme( int iColorIndex )
{
COLORREF clr = RGB( 0, 0, 0 );
switch( iColorIndex )
{
case GDC_HDR_BKGND:
clr = (COLORREF)GetSysColor( COLOR_3DFACE );
break;
case GDC_HDR_LINE:
clr = (COLORREF)GetSysColor( COLOR_3DSHADOW );
break;
case GDC_HDR_3DHL:
clr = (COLORREF)GetSysColor( COLOR_3DHILIGHT );
break;
case GDC_CELL_LINE:
clr = Ctd.ColorGet( m_hWndTbl, COLOR_IndexWindowText );
break;
}
return clr;
}
Second problem, if a new theme is introduced or colors change in a new release, again I have to determine the new/changed colors manually and must modify the internal M!Table function:
Code: Select all
COLORREF MTBLSUBCLASS::GetDefaultColor( int iColorIndex )
{
COLORREF clr = RGB( 0, 0, 0 );
#ifdef CTD5x
if ( QueryFlags( MTBL_FLAG_IGNORE_TD_THEME_COLORS ) )
{
clr = GetDefaultColorNoTheme( iColorIndex );
}
else
{
int iTheme = Ctd.ThemeGet( );
switch( iColorIndex )
{
case GDC_HDR_BKGND:
switch( iTheme )
{
case THEME_Office2007_R1:
clr = RGB( 205, 205, 205 );
break;
case THEME_Office2007_R2_LunaBlue:
case THEME_Office2007_R3_LunaBlue:
clr = RGB( 191, 219, 255 );
break;
case THEME_Office2007_R2_Obsidian:
case THEME_Office2007_R3_Obsidian:
clr = RGB( 173, 174, 189 );
break;
case THEME_Office2007_R2_Silver:
case THEME_Office2007_R3_Silver:
clr = RGB( 244, 247, 251 );
break;
default:
clr = GetDefaultColorNoTheme( iColorIndex );
}
break;
case GDC_HDR_LINE:
switch( iTheme )
{
case THEME_Office2007_R1:
clr = RGB( 124, 101, 101 );
break;
case THEME_Office2007_R2_LunaBlue:
case THEME_Office2007_R3_LunaBlue:
clr = RGB( 0, 107, 245 );
break;
case THEME_Office2007_R2_Obsidian:
case THEME_Office2007_R3_Obsidian:
clr = RGB( 79, 82, 119 );
break;
case THEME_Office2007_R2_Silver:
case THEME_Office2007_R3_Silver:
clr = RGB( 74, 127, 197 );
break;
default:
clr = GetDefaultColorNoTheme( iColorIndex );
}
break;
case GDC_HDR_3DHL:
switch( iTheme )
{
case THEME_Office2007_R1:
clr = RGB( 242, 242, 242 );
break;
case THEME_Office2007_R2_LunaBlue:
case THEME_Office2007_R3_LunaBlue:
clr = RGB( 239, 246, 255 );
break;
case THEME_Office2007_R2_Obsidian:
case THEME_Office2007_R3_Obsidian:
clr = RGB( 234, 234, 238 );
break;
case THEME_Office2007_R2_Silver:
case THEME_Office2007_R3_Silver:
clr = RGB( 252, 253, 254 );
break;
default:
clr = GetDefaultColorNoTheme( iColorIndex );
}
break;
case GDC_CELL_LINE:
switch( iTheme )
{
case THEME_Office2000:
case THEME_NativeXP:
clr = RGB( 128, 128, 128 );
break;
case THEME_Office2007_R1:
clr = RGB( 153, 153, 153 );
break;
case THEME_Office2007_R2_LunaBlue:
case THEME_Office2007_R3_LunaBlue:
clr = RGB( 79, 156, 254 );
break;
case THEME_Office2007_R2_Obsidian:
case THEME_Office2007_R3_Obsidian:
clr = RGB( 122, 124, 148 );
break;
case THEME_Office2007_R2_Silver:
case THEME_Office2007_R3_Silver:
clr = RGB( 153, 180, 217 );
break;
default:
clr = RGB( 112, 112, 112 );
}
break;
}
}
#else
clr = GetDefaultColorNoTheme( iColorIndex );
#endif;
return clr;
}
Regards
Michael