做个程序想做成这样,能实现吗?请教大侠!

解决方案 »

  1.   

    AllocConsole(); // 打开控制台窗口
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); // 取得输出句柄SetConsoleTitle("my console"); // 设控制台窗口标题
    Sleep(40); // 比你该死说要40毫秒才能保证标题设置完成
    HWND hWnd = FindWindow(NULL,"my console");BOOL MoveWindow(
      HWND hWnd,      // handle to window
      int X,          // horizontal position
      int Y,          // vertical position
      int nWidth,     // width
      int nHeight,    // height
      BOOL bRepaint   // repaint option
    ); // MoveWindow到view的坐标BOOL WriteConsole(
      HANDLE hConsoleOutput,           // handle to screen buffer
      CONST VOID *lpBuffer,            // write buffer
      DWORD nNumberOfCharsToWrite,     // number of characters to write
      LPDWORD lpNumberOfCharsWritten,  // number of characters written
      LPVOID lpReserved                // reserved
    ); // 输出到控制台窗口
    // 程序结束时关闭
    CloseHandle(hStdOut);
    hStdOut = NULL;
    FreeConsole();
      

  2.   

    http://www.codeguru.com/Cpp/W-D/console/redirection/article.php/c541/