bSuccess = GetConsoleScreenBufferInfo(hConsole, &csbi);
/* fill the entire screen with blanks */
bSuccess = FillConsoleOutputCharacter(hConsole, (TCHAR) ' ',

解决方案 »

  1.   

    参考:
    void cls()
    {
    // here's where we'll home the cursor 
    COORD coordScreen = { 0, 0 };
    BOOL  bSuccess;
    DWORD cCharsWritten;
    CONSOLE_SCREEN_BUFFER_INFO csbi;// to get buffer info
    DWORD dwConSize;// number of character cells in the current buffer
    HANDLE hConsoleOutput;
    // get the handle
    hConsoleOutput=GetStdHandle(STD_OUTPUT_HANDLE); 
    // get the number of character cells in the current buffer
     bSuccess=GetConsoleScreenBufferInfo(hConsoleOutput,&csbi );
     dwConSize=csbi.dwSize.X * csbi.dwSize.Y;
    // fill the entire screen with blanks 
    bSuccess=FillConsoleOutputCharacter(hConsoleOutput,
                         (TCHAR)' ',dwConSize,
     coordScreen,&cCharsWritten);
    // get the current text attribute 
    bSuccess=GetConsoleScreenBufferInfo(hConsoleOutput,&csbi);
    // now set the buffer's attributes accordingly
    bSuccess=FillConsoleOutputAttribute(hConsoleOutput,
                            csbi.wAttributes,dwConSize,
    coordScreen,&cCharsWritten);
    // put the cursor at (0, 0)
    bSuccess=SetConsoleCursorPosition(hConsoleOutput,
      coordScreen);
    return;
    }
    //
    void SetColor(unsigned short ForeColor=FOREGROUND_BLUE|FOREGROUND_INTENSITY,
      unsigned short BackGroundColor=BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE |BACKGROUND_INTENSITY) 
    { //给参数默认值,使它可以接受0/1/2个参数  
    HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);  //本例以输出为例 
    SetConsoleTextAttribute(hCon,ForeColor|BackGroundColor); 
    }; 
      

  2.   

    例子:int main()
    {
    COORD coordScreen = { 20, 2 };
    float divergency;
    digit *pLast=NULL;
    int   sel=0;
    char  goon[80];
    int   total;
    BOOL  bAppend=FALSE;
    DWORD written;
    //
    HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);  //本例以输出为例 
    //
    OutputDebugString("After InitFunc !\n");
    SetColor();
    //test
    //OnBnClickedButton1();
    do 
    {
    cls();
    //
    cout<< (char*)pTest <<endl;// "hello,world" line 0 , 1
    //
    cout << "\n\t###################################\n\n\n";// line 2
    cout << "\t1 Create/Append a measure value list\n\n";
    cout << "\t2 Display the measure value list\n\n";
    cout << "\t3 Measure value's mean value\n\n";
    cout << "\t4 Delete some measure values\n\n";
    cout << "\t5 Exit\n\n";
    cout << "\t###################################\n";
    cout << endl << "\nYour choice : ";
    //
    SetConsoleCursorPosition(hCon, coordScreen);
    WriteConsole(hCon,"xxxxxx",6,&written,0);
    其中:
    SetConsoleCursorPosition(hCon, coordScreen);
    WriteConsole(hCon,"xxxxxx",6,&written,0);
    把 cout << "\n\t###################################\n\n\n";// line 2
    改成:
    #######xxxxxx######################
      

  3.   

    void main( void ){
    int i=0;
    for(;i<10;i++)
    printf("%d \r",i);
    }//end of main