windows - C++ : Using background colors with clrscr() -
i making simple game. initial screen welcome screen following color:
system("color f3")//background:white , text:aqua then when invoke following main() function
void display() { sleep(2000); clrscr(); system("color f3"); cout<<"levels:\n\n"; int d; cout<<"1.easy\n"; cout<<"2.medium\n"; cout<<"3.hard\n"; cout<<"4.insane!\n"; cout<<"choose difficulty:"; cin>>d; } without statement system("color f3"); in display() background black, text gets highlighted in white , text color aqua.

i want know why above happens.
problem:
with statement system("color f3"); when clrscr() invoked, screen turns black few milliseconds , turns white , aqua.
so how prevent screen turn black few milliseconds?
thanks help:)
when call system(), lauch command processor in process, changes screen settings.
when later call clrscr() library clears uses own colors stored @ startup clear screen. why experience problem.
you instead use directly windows console api, example function setconsoletextattribute():
#include <windows.h> ... setconsoletextattribute(getstdhandle(std_output_handle), background_intensity|foreground_blue); note: colors , intensity can combined needed |. in case write 0xf3
by way, this question shows other native windows console api functions of interest.
Comments
Post a Comment