gpt4 book ai didi

c - 控制台隐藏光标失败?

转载 作者:太空宇宙 更新时间:2023-11-04 01:32:46 25 4
gpt4 key购买 nike

int main (void) 
{
//Get a console handle
HWND myconsole = GetConsoleWindow();

struct CONSOLE_CURSOR_INFO
{
DWORD dwSize;
BOOL bVisible;
};
struct CONSOLE_CURSOR_INFO CURSOR;

CURSOR.bVisible = FALSE;
SetConsoleCursorInfo(myconsole, CURSOR);
}

我想在控制台隐藏光标,但是失败了。

此处列出了哪些 GCC-mingw32 报告:

error: request for member 'bVisible' in something not a structure or union
error: incompatible type for argument 2 of 'SetConsoleCursorInfo'

谁能帮帮我?

谢谢。

最佳答案

#include <windows.h>
#include <wincon.h>
#include <stdio.h>

int main (void)
{
//Get a console handle
HANDLE myconsole = GetStdHandle(STD_OUTPUT_HANDLE);

/* It is already defined.
struct CONSOLE_CURSOR_INFO
{
DWORD dwSize;
BOOL bVisible;
};
*/
//CONSOLE_CURSOR_INFO is defined type.
CONSOLE_CURSOR_INFO CURSOR;

BOOL result;

CURSOR.dwSize = 1;
CURSOR.bVisible = FALSE;
result=SetConsoleCursorInfo(myconsole, &CURSOR);//second argument need pointer
if(result){//success
printf("test print\n");
getch();//wait
}
return 0;
}

关于c - 控制台隐藏光标失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20020746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com