#define NumSysColors (sizeof(SysPalIndex)/sizeof(SysPalIndex[1]))

#define rgbBlack RGB(0,0,0)

#define rgbWhite RGB(255,255,255)

//*** These are the GetSysColor display element identifiers

static int SysPalIndex[] = {

COLOR_ACTIVEBORDER,

COLOR_ACTIVECAPTION,

COLOR_APPWORKSPACE,

COLOR_BACKGROUND,

COLOR_BTNFACE,

COLOR_BTNSHADOW,

COLOR_BTNTEXT,

COLOR_CAPTIONTEXT,

COLOR_GRAYTEXT,

COLOR_HIGHLIGHT,

COLOR_HIGHLIGHTTEXT,

COLOR_INACTIVEBORDER,

COLOR_INACTIVECAPTION,

COLOR_MENU,

COLOR_MENUTEXT,

COLOR_SCROLLBAR,

COLOR_WINDOW,

COLOR_WINDOWFRAME,

COLOR_WINDOWTEXT

};

//*** This array translates the display elements to black and white

static COLORREF MonoColors[] = {

rgbBlack,

rgbWhite,

rgbWhite,

rgbWhite,

rgbWhite,

rgbBlack,

rgbBlack,

rgbBlack,

rgbBlack,

rgbBlack,

rgbWhite,

rgbWhite,

rgbWhite,

rgbWhite,

rgbBlack,

rgbWhite,

rgbWhite,

rgbBlack,

rgbBlack

};

//*** This array holds the old color mapping so we can restore them

static COLORREF OldColors[NumSysColors];

//*** AppActivate sets the system palette use and

//*** remaps the system colors accordingly.

void AppActivate(BOOL fActive)

{

HDC hdc;

int i;

//*** Just use the screen DC

hdc = GetDC(NULL);

//*** If the app is activating, save the current color mapping

//*** and switch to SYSPAL_NOSTATIC

if (fActive && GetSystemPaletteUse(hdc) == SYSPAL_STATIC)

{

//*** Store the current mapping

for (i=0; i<NumSysColors; i++)

OldColors[i] = GetSysColor(SysPalIndex[i]);

//*** Switch to SYSPAL_NOSTATIC and remap the colors

SetSystemPaletteUse(hdc, SYSPAL_NOSTATIC);

SetSysColors(NumSysColors, SysPalIndex, MonoColors);

}

else if (!fActive)

{

//*** Switch back to SYSPAL_STATIC and the old mapping

SetSystemPaletteUse(hdc, SYSPAL_STATIC);

SetSysColors(NumSysColors, SysPalIndex, OldColors);

}

//*** Be sure to release the DC!

ReleaseDC(NULL,hdc);

}