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);
}
Run Code Online (Sandbox Code Playgroud)
我想在控制台中隐藏光标,但失败了。
此处列出了 GCC-mingw32 报告的内容:
error: request for member 'bVisible' in something not a structure or union
error: incompatible type for argument 2 of 'SetConsoleCursorInfo'
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我吗?
谢谢。
#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;
}
Run Code Online (Sandbox Code Playgroud)