如何在C ++ Microsoft Visual Studio WinApi中打开弹出窗口时禁用父窗口。基本上,我希望我的弹出窗口像一个模式对话框一样。我在互联网上发现此消息循环,说它应该执行此操作,但事实并非如此。当我打开应用程序时,父窗口已被禁用,我无法对其进行任何操作。下面,我将提供在程序中使用的消息循环。要如何在打开弹出窗口时禁用父窗口,并且在关闭弹出窗口后如何启用后退父窗口?
BOOL fDone;
INT nResult = 0;
int RunModalWindow(
HWND hwndPopup,
HWND hWndParent);
if (hWndParent != NULL) {
EnableWindow(hWndParent, FALSE);
}
MSG msg;
for (fDone = FALSE; !fDone; WaitMessage())
{
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
fDone = TRUE;
PostMessage(NULL, WM_QUIT, 0, 0);
break;
}
if (!IsDialogMessage(hwndPopup, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
if (hWndParent != NULL)
EnableWindow(hWndParent, TRUE);
DestroyWindow(hwndPopup);
return nResult;
}