Jan 4, 2014 at 9:34am Jan 4, 2014 at 9:34am UTC
I have researched a c++ code that outputs a dialog. It outputs the dialog in different color for every letter and changes the background to white.
What i want is to make it output just a single color, specifically color yellow and the backgroud should be black in order for the user to see it clearly. Also, i want to make it output faster. How would i do this?
Here is the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#include <conio.h>
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
void WaitKey();
int main()
{
int len = 0,x, y=240;
string text = "WELCOME USER!!" ;
len = text.length();
cout << endl << endl << endl << "\t\t" ;
for ( x=0;x<len;x++)
{
SetConsoleTextAttribute(console, y);
cout << text[x];
y++;
if ( y >254)
y=240;
Sleep(250);
}
SetConsoleTextAttribute(console, 16);
cin.get();
cin.get();
return 0;
}
Last edited on Jan 4, 2014 at 9:38am Jan 4, 2014 at 9:38am UTC
Jan 4, 2014 at 9:56am Jan 4, 2014 at 9:56am UTC
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
system("Color 0E" );
std::cout << "\t\t\t Hello World" << std::endl;
cin.ignore();
return 0;
}
I should probably mention that system is generally frowned upon, but its probably the easiest way to accomplish this
http://www.cplusplus.com/articles/j3wTURfi/
Last edited on Jan 4, 2014 at 10:00am Jan 4, 2014 at 10:00am UTC
Jan 4, 2014 at 10:07am Jan 4, 2014 at 10:07am UTC
thanks for that. but can you make the dialog appear as what the code above have done?.i,e., every letter will not appear simultaneously but rather one after another..?
Jan 4, 2014 at 10:25am Jan 4, 2014 at 10:25am UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <cstring>
#include <Windows.h>
using namespace std;
int main()
{
char text[] = "Hello World" ;
system("Color 0E" );
for (int i = 0; i < strlen(text); i++)
{
cout << text[i];
Sleep(200);
}
cin.ignore();
return 0;
}
Last edited on Jan 4, 2014 at 10:29am Jan 4, 2014 at 10:29am UTC
Jan 4, 2014 at 10:30am Jan 4, 2014 at 10:30am UTC
thank you so much. you are great!