简体   繁体   English

如何将光标位置设置为其默认值

[英]how to set cursor position to its default

I have used gotoxy() function to set cursor position to specific points that help me to reorder the values as shown in picture .我已经使用 gotoxy() 函数将光标位置设置为特定点,以帮助我重新排序如图所示的值。 Now I want the "press any key to continue" statement and the referred zero value to be set at the bottom of the screen how I can do this现在我想在屏幕底部设置“按任意键继续”语句和引用的零值,我该怎么做

在此处输入图片说明

Here is the code for gotoxy() function:这是 gotoxy() 函数的代码:

void gotoxy(int x, int y) 
{ 
COORD coord;
coord.X = x; 
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

You can get the current position using GetConsoleScreenBufferInfo .您可以使用GetConsoleScreenBufferInfo获取当前位置。

Something like:就像是:

COORD GetXY()
{
    CONSOLE_SCREEN_BUFFER_INFO info;
    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info);
    return info.dwCursorPosition;
}

It appears that your gotoxy() works.看来您的 gotoxy() 有效。

So simply set the cursor to "top left" of the screen (or to your favorite location?) prior to prompting for "press any key to continue".因此,在提示“按任意键继续”之前,只需将光标设置到屏幕的“左上角”(或您最喜欢的位置?)。

You own the cursor!您拥有光标!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM