gizmo385

Load Program Code

May 21st, 2011
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.96 KB | None | 0 0
  1. void loadTextColor()
  2. {
  3.     ifstream myfile;
  4.     HANDLE hConsoleOut; //handle to the console
  5.     hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
  6.     int textColorSelection;
  7.     int backgroundColorSelection;
  8.  
  9.     myfile.open("text.txt");
  10.     while(myfile.is_open())
  11.     {
  12.         myfile >> textColorSelection;
  13.         if(textColorSelection == 1)
  14.         {
  15.             SetConsoleTextAttribute(hConsoleOut, FOREGROUND_GREEN);
  16.             myfile.close();
  17.             break;
  18.         }
  19.         else if(textColorSelection == 2)
  20.         {
  21.             SetConsoleTextAttribute(hConsoleOut, FOREGROUND_BLUE);
  22.             myfile.close();
  23.             break;
  24.         }
  25.         else if(textColorSelection == 3)
  26.         {
  27.             SetConsoleTextAttribute(hConsoleOut, FOREGROUND_RED);
  28.             myfile.close();
  29.             break;
  30.         }
  31.         else
  32.         {
  33.             myfile.close();
  34.             break;
  35.         }
  36.  
  37.     }
  38.  
  39.     system("cls");
  40.     loadBackgroundColor();
  41. }
  42.  
  43. void loadBackgroundColor()
  44. {
  45.     ifstream myfile;
  46.     HANDLE hConsoleOut; //handle to the console
  47.     hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
  48.     int backgroundColorSelection;
  49.  
  50.     myfile.open("background.txt");
  51.     while(myfile.is_open())
  52.     {
  53.         myfile >> backgroundColorSelection;
  54.         if(backgroundColorSelection == 1)
  55.         {
  56.             SetConsoleTextAttribute(hConsoleOut, BACKGROUND_GREEN);
  57.             myfile.close();
  58.             break;
  59.         }
  60.         else if(backgroundColorSelection == 2)
  61.         {
  62.             SetConsoleTextAttribute(hConsoleOut, BACKGROUND_BLUE);
  63.             myfile.close();
  64.             break;
  65.         }
  66.         else if(backgroundColorSelection == 3)
  67.         {
  68.             SetConsoleTextAttribute(hConsoleOut, BACKGROUND_RED);
  69.             myfile.close();
  70.             break;
  71.         }
  72.         else
  73.         {
  74.             myfile.close();
  75.             break;
  76.         }
  77.  
  78.     }
  79.  
  80.     system("cls");
  81.     mainMenu();
  82. }
Advertisement
Add Comment
Please, Sign In to add comment