The colors of Windows console is changed

Hi Rooters!

Since ROOT 5.30.00 the strange behavior of console color on Windows is observed. If one set the suitable colors of background and text of the Windows console than ROOT changed these colors. The background becomes the black. It was not with older versions of the ROOT. The attempts of change the system.rootrc file in the /root/etc directory did not get the success.

Is it possible to save the Windows console colors after the ROOT start?

Sincerely Yours,

You mean ROOT changes the color background of the terminal you are running it ?
I do see this using cygwin on XP.

The Cygwin is not used. The binary ROOT version created for the Windows with Visual Studio 9 is downloaded. The colors of cmd screen are set. After the start of ROOT the background color is changed on black. It was not so until version 5.30.00.

Ok we will look.


For that, Windows would need to tell me which console (background) color is the current default. I cannot find it as part of Windows’ WIN32 API - can you?

Cheers, Axel.


The next example gives the current console background. It was got from the site and checked on the local computer with Windows 7 and Visual Studio 9.

Best regards,

#include <windows.h>
#include <stdio.h>

int GetColor();
int GetForground();
int GetBackground();

int main()
	int color, cback, cforg, key = 0;

	color = GetColor();
	cback = GetBackground();
	cforg = GetForground();

		printf("COLOR = %d\n",color);
		printf("CBACK = %d\n",cback);
		printf("CFORG = %d\n",cforg);

	return 0;

int GetColor()
     WORD wColor = 0;
     //We will need this handle to get the current background attribute
     HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
     //We use csbi for the wAttributes word.
     if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
        //return the wAttributes data
          wColor = (csbi.wAttributes & 0xFF);
     return wColor;
int GetForground()
    //Mask out all but the lower nibble
    return GetColor() & 0x0F;
int GetBackground()
    // Shift down one nibble (4bits) and then mask off everything else
    return (GetColor() >> 4) & 0x0F;


Awesome, thanks! In the trunk, ROOT now reverts the terminal to the colors that were set before ROOT started. Could you confirm by checking tomorrow’s ROOT build from (assuming we didn’t break ROOT in the meantime :slight_smile:?

Thanks for your good find!



I got root_trunk-snapshot-2012-07-24_r45170.Win32-i686-MSVC2010. It was checked on the Windows 7.
The background color of the screen is changed on the black. The screenshot is attached.

Best regards,