C++ 得到光标坐标和移动光标

C++ 得到光标位置 和 移动光标,网上转的。

 

 

void appGetXY() 
{ 
	HANDLE hStdout;
	CONSOLE_SCREEN_BUFFER_INFO pBuffer; 
	hStdout = GetStdHandle(STD_OUTPUT_HANDLE); 
	GetConsoleScreenBufferInfo(hStdout, &pBuffer); 
	cout << pBuffer.dwCursorPosition.X << pBuffer.dwCursorPosition.Y <<endl;; 
}

 

 

 

void appGotoXY(int x,int y)  
{
    CONSOLE_SCREEN_BUFFER_INFO    csbiInfo;                            
    HANDLE    hConsoleOut;
    hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleScreenBufferInfo(hConsoleOut,&csbiInfo);
    csbiInfo.dwCursorPosition.X = x;                                    
    csbiInfo.dwCursorPosition.Y = y;                                    
    SetConsoleCursorPosition(hConsoleOut,csbiInfo.dwCursorPosition);   
}
posted @ 2010-10-12 18:56  noevil  阅读(8915)  评论(0编辑  收藏  举报