控制台程序中划线更新后消失怎么办?
#include <windows.h>#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
#include <tchar.h>
extern "C"
{
WINBASEAPI HWND WINAPI GetConsoleWindow();
}
int main(int argc, char *argv[]) //主线程运行结束,辅助线程也结束。
{
HWND hwnd;
HDC hdc;
printf("There are some words in console window!\n在控制台窗口中绘图!\n");
system("Color 3D");
hwnd = GetConsoleWindow();
hdc = GetDC(hwnd);
LineTo(hdc, 200, 300);
Rectangle(hdc, 10, 30, 300, 50);
TextOut(hdc, 10, 10, _TEXT("Hello World\nYesNoConcel!"), 20);
ReleaseDC(hwnd, hdc);
getche();
printf("After drawing!\n");
return 0;
}
用上面的程序在VC控制台上划了一条线,但是刷新后这线就消失了,怎么才能保持刷新时不消失呢 ?