gpt4 book ai didi

c++ - DX9 从全屏切换到窗口给错误的客户区

转载 作者:行者123 更新时间:2023-11-30 05:09:45 26 4
gpt4 key购买 nike

我的 dx9 应用程序有点问题。当我使用客户区下方的代码从全屏切换回窗口模式时,它的大小不正确,它变小了。AdjustWindowRect 函数正在正确执行其任务,但 SetWindowPos 未设置正确的窗口大小。也许我错过了什么。任何想法。

if (d3dpp.Windowed && resChoice == resolutionchoice) return false; // already in window mode and same resolution
//MessageBox(NULL, L"switching to window", L"ERROR", MB_OK);
resChoice = resolutionchoice;
screenWidth = resolutionwidth[resChoice];
screenHeight = resolutionheight[resChoice];
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; // set the back buffer format to 32-bit
d3dpp.BackBufferWidth = screenWidth; // set the width of the buffer
d3dpp.BackBufferHeight = screenHeight; // set the height of the buffer
d3dpp.Windowed = true;

SetWindowLong(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW); // WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_MINIMIZEBOX );
// need to call SetWindowPos as well
string values;
RECT r = { 0,0,screenWidth,screenHeight };

AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW, false);

values = std::to_string(r.left);
OutputDebugStringA("Adjust area = ");
OutputDebugStringA(values.c_str()); OutputDebugStringA(",");
values = std::to_string(r.top);
OutputDebugStringA(values.c_str()); OutputDebugStringA(",");
values = std::to_string(r.right);
OutputDebugStringA(values.c_str()); OutputDebugStringA(",");
values = std::to_string(r.bottom);
OutputDebugStringA(values.c_str()); OutputDebugStringA("\n");

SetWindowPos(hWnd, HWND_TOP, r.left, r.top, r.right - r.left , r.bottom - r.top, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_FRAMECHANGED);//
//screenWidth = SCREEN_WIDTH;
//screenHeight = SCREEN_HEIGHT;
//windowXscale = 1;
//windowYscale = 1;
GetClientRect(hWnd, &r);

values = std::to_string(r.left);
OutputDebugStringA("Client area = ");
OutputDebugStringA(values.c_str()); OutputDebugStringA(",");
values = std::to_string(r.top);
OutputDebugStringA(values.c_str()); OutputDebugStringA(",");
values = std::to_string(r.right);
OutputDebugStringA(values.c_str()); OutputDebugStringA(",");
values = std::to_string(r.bottom);
OutputDebugStringA(values.c_str()); OutputDebugStringA("\n");
}

最佳答案

经过更多搜索发现,如果您使用 SetWindowPos 并尝试制作一个比桌面大的窗口,或者在这种情况下从全屏返回时,windows 将发送一条消息,窗口大小将自动调整以制作它不大于当前桌面大小。

在 SetWindowPos api 调用中添加 SWP_NOSENDCHANGING 标志可以阻止这种情况发生,客户端大小将是您想要的。

关于c++ - DX9 从全屏切换到窗口给错误的客户区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45995772/

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