在 Visual Studio 中为选定文本添加闪烁效果、文本颜色和背景文本颜色

问题描述

我是 C++ 的新手。我目前正在将我的主菜单(即 Turbo C++ 代码)转换为 Visual Studio。我已经在 Turbo C++ 中常用的一些函数中找到了解决方案。我的主要问题是,我不知道如何手动突出显示某些选定的文本。我曾经玩过 textcolor(COLOR + BLINK);因为我们的教授要求我们这样做,但似乎它在 Visual Studio 中不起作用。我也试过系统(“颜色XY”),但它突出显示了lmao的所有文本。到目前为止,这是我转换后的代码(已修剪)。

Here's the image that I want to display in Visual Studio

//| Header
#include <iostream>
#include <conio.h>
#include <process.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <Windows.h>
#define clrscr(); system("cls");
#define getch(); _getch()

using namespace std;

void gotoxy(int x,int y)
{
    COORD coord;
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}

void clreol(void)
{
    cin.clear();
    cin.ignore();
}

//Refresher Loop Variable
int refresh = 1;

char main_input;
char s_input;
char se_input;
char l_input;
char l_option;
char a_input;
int trigger;

//|-------------------------------------------------------------(Main Lobby)-
//---------------------------------------------------------------------------
int main(void) {
clrscr();

while(refresh == 1)
do {
clrscr();

gotoxy(30,8);  
system("Color 80");
cout << "      Main Menu      ";


gotoxy(30,10); system("Color D7");
cout << "A"; 
system("Color 07");  cout << " - Sequence";

gotoxy(30,11); system("Color 17");
cout << "B";    
system("Color 07"); cout << " - Selection";

gotoxy(30,12); system("Color 27");
cout << "C";    
system("Color 07"); cout << " - Iteration";

gotoxy(30,13); system("Color 67");
cout << "D";    
system("Color 07"); cout << " - Arrays final exam   ";

gotoxy(30,14); system("Color 47");
cout << "E";    
system("Color 07"); cout << " - Exit";

gotoxy(30,16);
    cout << "Enter your choice: ";
            cin >> main_input;

switch(main_input) {
    case 'A': sequence();
    break;

    case 'B': selection();
    break;

    case 'C': loops();
    break;

    case 'D': arrays();
    break;

    case 'E':
        exit(0);
    break;
} // End of switch

} while(refresh == 1); // End of do while

getch();

}

谢谢:)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)