Windows 7 上由全屏 OpenGL 窗口打开的模态对话框未显示 [英] Modal dialogs opened by a fullscreen OpenGL window on Windows 7 are not showing

查看:21
本文介绍了Windows 7 上由全屏 OpenGL 窗口打开的模态对话框未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看来我的问题可能与未回答的相关问题相同(OpenGL with GLUT on windows 7,全屏模式不显示消息框).

It seems that my problem may be the same as an unanswered related question (OpenGL with GLUT on windows 7, fullscreen mode not showing the message box).

自从我切换到 Win7 作为开发环境以及我的应用程序可能的目标平台后,我注意到它们的行为出现了退化.

Since I switched to Win7 as a development environment, and a possible target platform for my applications, I noticed a regression in their behaviour.

每当我有一个包含全屏 OpenGL 上下文的全屏窗口时,应用程序在显示模式对话框(例如消息框、文件打开对话框等)时都会出现问题

Whenever I have a fullscreen window containing a fullscreen OpenGL context, the applications have problems displaying modal dialog boxes (such as message boxes, file open dialog, etc.)

这个窗口是用 WS_POPUP 样式创建的.GL 上下文没有什么花哨的.Windows XP 一切正常.

The window is just created with WS_POPUP style. The GL context is nothing fancy. And everything is fine with Windows XP.

Windows 7 下的问题是模式对话框在打开时是不可见的(可能它们出现在全屏窗口后面).您必须在应用程序上按 Alt-Tab 才能显示对话框.

The problem under Windows 7 is that the modal dialog boxes are invisible at their opening (maybe their appear behind the full screen window). You have to Alt-Tab the application to have the dialogs appear.

这是一个主要问题,因为应用程序似乎被冻结,而实际上它正在等待用户输入.

This is a major problem as the application appears to be frozen, while it in fact waits for user input.

有人遇到过这种行为吗?有人知道解决方法吗?

Did anyone encounter this behaviour ? Does anyone know a workaround ?

我很快就制作了一个示例测试应用程序;它的源代码可以在 http://pastebin.com/K4v2NNDs 找到.一个简单的 MSVC8 项目可以在 这里.

I've quickly made up a sample test application ; its source code can be found at http://pastebin.com/K4v2NNDs. A simple MSVC8 project can be found here.

PS.我也在 opengl.org 论坛上发过帖子,对那些关注这两个论坛的人深表歉意.

PS. I've also posted on opengl.org forums, sorry for those of you that follow both.

编辑

感谢 Chris 的评论,我已经测试了各种事件的模式对话框,例如 WM_TIMER 或 WM_RBUTTONUP,但问题仍然存在.

Thanks to Chris comment, I've tested the modal dialog on various events, such as WM_TIMER or WM_RBUTTONUP, but the problem is still there.

我还用DWM_EC_DISABLECOMPOSITION"调用了DwmEnableComposition",只是为了检查:问题仍然存在.

I've also called 'DwmEnableComposition' with 'DWM_EC_DISABLECOMPOSITION' just to check : problem still there.

我还通过用 DirectX 替换 OpenGL 位来测试应用程序,这样一切都按预期工作......确实是 OpenGL 导致了问题.

I've also tested the application by replacing the OpenGL bits by DirectX, and this way everything works as expected... It's really OpenGL causing the problem.

(更新了 pastebin http://pastebin.com/Rq1Ehm3w 和我的暂存器)

(updated pastebin http://pastebin.com/Rq1Ehm3w and my scratchpad)

编辑

Windows 8 也存在此问题.

The problem also exists on Windows 8.

推荐答案

解决方法是 由 Joseph Steel 在 opengl.org 上发布,因此,我也将其放在这里作为参考:

A workaround has been posted on opengl.org by Joseph Steel, so, for reference I put it here as well :

我为这个问题找到的解决方案是确保窗口的像素格式使用 WGL_SWAP_COPY_ARB 交换方法而不是 WGL_SWAP_EXCHANGE_ARB.

The solution I found for this problem was to ensure that the pixel format for the window uses the WGL_SWAP_COPY_ARB swap method rather than the WGL_SWAP_EXCHANGE_ARB.

我注意到必须使用wglChoosePixelFormatARB"来获取像素格式.

I've noted that one must use 'wglChoosePixelFormatARB' to obtain the pixel format.

我尝试使用带有PFD_SWAP_COPY"标志的经典ChoosePixelFormat",但它在我的系统(Win7 x64 + NVidia GeFo 9600GT v196.21)上不起作用,因为它总是返回带有PFD_SWAP_EXCHANGE"的像素格式.

I tried with the classic 'ChoosePixelFormat' with the 'PFD_SWAP_COPY' flag, but it does not work on my system (Win7 x64 + NVidia GeFo 9600GT v196.21) as it always returns me a pixel format with 'PFD_SWAP_EXCHANGE' instead.

我对结果只有一半满意,因为它在我的显示中引入了一些撕裂,但至少它有效!

I'm only half-happy with the results, as it introduces some tearing in my display, but as least it works !

作为参考,我更新了我的 测试源代码.

For reference, I've updated my test source code.

编辑,2013 年 12 月

此解决方法不再有效,至少在我的系统(笔记本电脑,Optimus GeForce 650M)上无效.WGL_SWAP_COPY_ARB 已设置,但模式对话框未显示.到目前为止,似乎创建具有 1 像素边框的窗口(将 WS_BORDER 添加到 WS_POPUP 样式)可以解决问题,并防止进入全屏"模式.

This workaround does not work anymore, at least on my system (laptop, Optimus GeForce 650M). The WGL_SWAP_COPY_ARB is setup but the modal dialog does not show. So far, it seems that creating the window with a 1 pixel border (adding WS_BORDER to WS_POPUP style) does the trick, and prevents entering 'fullscreen' mode.

这篇关于Windows 7 上由全屏 OpenGL 窗口打开的模态对话框未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆