如何在视觉对象中创建 UI C++

How to create UI in C++ visual

本文关键字:创建 UI C++ 对象 视觉      更新时间:2023-10-16

我是C++和Visual Studio的新手,任何人都可以帮助我创建满足以下要求的UI吗?

要求:有一个包含 10 个测试用例的.txt文件。在UI中,我(测试人员)应该能够选择他/她选择的测试用例来运行。

尝试使用 MFC 项目。您可以在 GUI 工具箱中找到下拉菜单。在MFC中进一步学习。

参考这个 - https://www.youtube.com/watch?v=6hSYZdvQ3s4&index=1&list=WL

请考虑使用命令行界面的可能性,如以下模板所示:

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
    // check that parameter is given in command line when program is run
    if(argc != 2) // if number of parameters is insufficient 
    {   // explaine and stop
        cout << "Please, run a program with parameter: name of file with testcases" << endl;
        cout << "For example:" << endl << " " << argv[0] << " tests.txt" << endl;
        return 1;
    }
    // try to open file with test cases
    ifstream testfile;
    testfile.open(argv[1], ifstream::in);
    if( !testfile.is_open() )
    {
        cout << "ERROR: File " << argv[1] << " cannot be open!" << endl;
        return 2;
    }
    // read test cases from file
    string testCaseName;
    char answer;
    while( getline(testfile, testCaseName).good() )
    {
        if(testfile.eof())
        {
            break;
        }
        if(testCaseName.length() == 0)
        {
            continue;
        }
        cout << "Would you like to execute testcase " << testCaseName << " ? (Y/N): ";
        cin >> answer;
        if( answer == 'Y' || answer == 'y')
        {
            cout << "Test execution... " << endl;
            // run test case
            // . . .
            // report test results
            // . . .
        }
    }
    return 0;
}

要使用此类程序运行测试,您应该在命令行中键入:

 programname test_file.txt