所以我试图让我的窗口类全屏,但它不起作用,它只是闪烁黑色然后它不会成为全屏这里是源代码: -
void InitEngine::Init(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd, DesktopScreenInfo * ScreenInfo, LPSTR WindowName)
{
mWindoClass = new WNDCLASSEX();
ZeroMemory(mWindoClass,sizeof(WNDCLASSEX));
if(ScreenInfo) mScreenInfo = ScreenInfo;
else mScreenInfo = &DesktopScreen::GetScreenInfo();
mWindoClass->cbSize = sizeof(WNDCLASSEX);// window size
mWindoClass->style = CS_HREDRAW | CS_VREDRAW; // so it draw when Horizontal or Vertical change
mWindoClass->lpfnWndProc = WindowProc;
mWindoClass->hInstance = hInstance;
mWindoClass->hCursor = LoadCursor(NULL, IDC_ARROW); //load normal cursor
mWindoClass->hbrBackground = (HBRUSH)COLOR_WINDOW;
mWindoClass->lpszClassName = "PoPEngineClass";
DEVMODE screen;
memset(&screen,0,sizeof(screen));
screen.dmSize = sizeof(screen);
screen.dmPelsWidth = mScreenInfo->Width;
screen.dmPelsHeight = mScreenInfo->Height;
screen.dmBitsPerPel = mScreenInfo->ScreenDepth;
screen.dmDisplayFrequency = mScreenInfo->FrameRate;
screen.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
ChangeDisplaySettings(&screen, CDS_FULLSCREEN);
RegisterClassEx(mWindoClass);
WindowHandel = CreateWindowEx(NULL , mWindoClass->lpszClassName , WindowName , WS_POPUP, 0 , 0, mScreenInfo->Width, mScreenInfo->Height, NULL, NULL, hInstance, NULL);
ShowWindow(WindowHandel, nShowCmd);
UpdateWindow(WindowHandel);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
答案 0 :(得分:0)
ChangeDisplaySettings实际上并没有全屏显示窗口 - 尽管标志的名称可能有误导性。要使一个窗口全屏显示,你基本上必须自己做一堆工作:
对同一个问题elsewhere on SO有几个答案 - 但是它们存在问题。相反,建议阅读Raymond Chen关于此问题的博客文章:How do I cover the taskbar with a fullscreen window? - 他在上面列出的任何内容之间的区别在于他正在创建一个新窗口而不修改现有窗口;这实际上是一种更简洁的方法,因为这意味着你不需要处理记住/恢复原来的位置。
ChangedisplaySetting的CDS_FULLSCREEN
标志有不同的含义:调用是用于更改显示模式设置,而不是使窗口全屏;但是标志告诉窗口模式更改是临时的,所以不应该保存。例如,如果以特定分辨率播放视频的应用程序全屏显示,则可能需要更改实际屏幕分辨率以匹配视频,但只要它是全屏即可。或者OpenGL游戏或类似游戏可能会使用它来确保它以特定分辨率运行全屏。所以它真的意味着“将显示设置更改为这些,但我这样做只是因为我要全屏,所以不要让更改永久化。”Raymond Chan写了更多关于这个标志on his blog here如果您不关心屏幕分辨率设置,并且您只希望窗口占用所有屏幕区域,那么您不需要此呼叫。