【发布时间】:2018-03-18 16:45:40
【问题描述】:
我有一个将 Win32 控制台设置为全屏的功能。问题是当它进入全屏时,它并没有隐藏鼠标光标。
是否全屏似乎并不重要。当我调用 ShowCursor(FALSE) 时,鼠标光标仍然显示。怎么隐藏?
与 ShowCursor() 的文档中一样,如果函数返回大于 0 的值,光标将隐藏。如果为负数,它将隐藏。该值为我返回 -2,因此在这种情况下它应该隐藏,但事实并非如此。
bool Console::setFullScreen(const bool fullScreen)
{
HWND handle;
if (fullScreen)
{
// Hide the scrollbar
showScrollBar(false);
// Set the window style
handle = GetConsoleWindow();
LONG style = GetWindowLong(handle, GWL_STYLE);
style &= ~(WS_BORDER | WS_CAPTION | WS_THICKFRAME);
SetWindowLong(handle, GWL_STYLE, style);
// Set the window to full screen in windowed mode
ShowWindow(getHandle(), SW_MAXIMIZE);
// Hide the cursor
ShowCursor(FALSE); // Fails
}
else
{
showScrollBar(true);
// Set the window style
handle = GetConsoleWindow();
LONG style = GetWindowLong(handle, GWL_STYLE);
style |= WS_BORDER;
style |= WS_CAPTION;
style |= WS_THICKFRAME;
SetWindowLong(handle, GWL_STYLE, style);
// Set the window to full screen in windowed mode
ShowWindow(getHandle(), SW_NORMAL);
// Show the cursor
ShowCursor(TRUE);
}
return true;
}
【问题讨论】:
-
控制台窗口托管在另一个进程中。隐藏进程的鼠标光标不会隐藏控制台进程。
-
好像是这样。我想以编程方式将鼠标的光标位置移出屏幕是另一种选择。
-
最大化不等于全屏,Windows Vista+不支持硬件全屏控制台。