无模式,无父wxDialog在z顺序中总是高于wxFrame窗口吗? [英] Modeless, parentless wxDialog still always above wxFrame window in z-order?

查看:337
本文介绍了无模式,无父wxDialog在z顺序中总是高于wxFrame窗口吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序打开一个基于wxFrame的窗口和多个无模式和无父wxDialog的窗口。除了基于wxDialog的窗口坚持总是在基于wxFrame的窗口之上之外,它一切都很漂亮。

My program opens a wxFrame-based window and multiple modeless and parentless wxDialog-based windows. It all works beautifully, except that the wxDialog-based windows insist on always being on top of the wxFrame-based one.

我知道 wxDIALOG_NO_PARENT ,我正在使用它。当我关闭wxFrame时,对话框保持打开,所以他们绝对没有wxFrame窗口作为父对象。

I know about wxDIALOG_NO_PARENT, and I'm using it. The dialogs stay open when I close the wxFrame, so they definitely don't have the wxFrame window as a parent.

(如果重要的话,我使用C ++, wxWidgets 2.8.something,并在Ubuntu Linux上运行它。我的程序没有准备在任何其他平台上编译,所以我还没有在其他平台上测试它。)

(If it matters, I'm using C++, wxWidgets 2.8.something, and running it on Ubuntu Linux. My program isn't ready to compile on any other platform, so I haven't tested it on others yet.)

我想要全部窗口完全独立操作,因此用户可以使用wxFrame窗口以及wxDialog窗口。

I want all the windows to operate entirely independently, so the user can use the wxFrame window as well as the wxDialog ones. Can anyone point me in the right direction?

推荐答案

我不使用wxWidgets或Gtk(长期Qt / KDE!但是,粗略看看wxWidgets通用对话框代码的源代码揭示了 wxSTAY_ON_TOP 中的提及wxDialogStyle

I don't use wxWidgets or Gtk (long live Qt / KDE!) But...a cursory look at the source for the wxWidgets generic dialog code reveals a mention of wxSTAY_ON_TOP in wxDialogStyle:

http://trac.wxwidgets.org/browser/wxWidgets/trunk/src/common/dlgcmn.cpp#L57

文档声明 wxDEFAULT_DIALOG_STYLE 等效于wxCAPTION,wxCLOSE_BOX和wxSYSTEM_MENU(最后一个不在Unix下使用)的组合。但是考虑到省略其他选项,例如 wxNO_3D wxDIALOG_NO_PARENT 等等,我会疯狂猜文档不是最新的,并且 wxSTAY_ON_TOP 标志也可以默认应用于所有对话框。

The documentation states that wxDEFAULT_DIALOG_STYLE is "Equivalent to a combination of wxCAPTION, wxCLOSE_BOX and wxSYSTEM_MENU (the last one is not used under Unix)". But given the omission of other options like wxNO_3D, wxDIALOG_NO_PARENT, etc. I'm going to make a wild guess that the documentation is not up to date, and that the wxSTAY_ON_TOP flag may also be applied by default to all dialogs.

因此,对于每个无模式对话框,您可以在创建它们后尝试类似这样的对象:

So for each of your modeless dialogs, you could try something like this after they are created:

long style = iShouldBeUsingQtDialog->GetWindowStyleFlag();
if (style & wxSTAY_ON_TOP) {
    // set breakpoint here to see if it's set, because some flags 
    // can't be changed after window creation (hence just because 
    // this doesn't work doesn't mean it doesn't have the style)
    iShouldBeUsingQtDialog->SetWindowStyleFlag(style & ~wxSTAY_ON_TOP);
}

也许这将有助于...

Maybe that will help...

UPDATE:

什么,我安装了wxWidgets和Gnome和实验了一点。看起来这种行为来自于Gnome如何处理具有不同类型提示的窗口的区别...它将它们放入自己的z-index分组:

Okay, since the above didn't do anything, I installed wxWidgets and Gnome and experimented a bit. It seems that this behavior comes from a difference in how Gnome handles windows with different "type hints"...it puts them into their own z-index groupings:

http://developer.gnome.org/gdk/stable/gdk-Windows。 html#GdkWindowTypeHint

此对话框是使用 GDK_WINDOW_TYPE_HINT_DIALOG 创建的, GDK_WINDOW_TYPE_HINT_NORMAL 。做出此决定的点在 gtk / toplevel.cpp 中,并且由额外样式标志包含 wxTOPLEVEL_EX_DIALOG

The dialog is created with GDK_WINDOW_TYPE_HINT_DIALOG while your other window is most likely created with GDK_WINDOW_TYPE_HINT_NORMAL. The point where this decision is made is in gtk/toplevel.cpp and it's being cued by the fact that the "extra" style flags contain wxTOPLEVEL_EX_DIALOG:

http://trac.wxwidgets.org/browser/wxWidgets/trunk/src/gtk/toplevel.cpp#L543

这些只是在wxWidgets GTK代码库中对 gtk_window_set_type_hint 的两个调用,除了在启动屏幕代码中。所以改变额外样式位后事实不会有帮助。 (正确的解决方案是补丁wxWidgets,以便调整额外样式中的 wxTOPLEVEL_EX_DIALOG 可以适当调整窗口类型提示。)

Those are the only two calls to gtk_window_set_type_hint in the wxWidgets GTK codebase, except for in the splash screen code. So changing the "extra" style bits after the fact isn't going to help. (The "correct" solution would be to patch wxWidgets so that adjusting wxTOPLEVEL_EX_DIALOG in the extra styles would do the proper adjustment to the window type hint.)

不能使用wxDialog类,而是不通过其构造函数调用非虚拟方法 wxDialog :: Create wxTOPLEVEL_EX_DIALOG 的额外样式,然后直接进入顶级窗口创建:

You can't use the wxDialog class without running through its constructor, which calls the non-virtual method wxDialog::Create, which sets the extra style to wxTOPLEVEL_EX_DIALOG and then goes directly to top level window creation:

http://trac.wxwidgets.org/browser/wxWidgets/trunk/src/gtk/ dialog.cpp#L53

所以我想你可以尝试这个选项,如果你还没有显示对话窗口: p>

So I guess you have the option of trying this, which works if you haven't shown the dialog window yet:

#ifdef __WXGTK__
gtk_window_set_type_hint(
    GTK_WINDOW(iShouldBeUsingQtDialog->GetHandle()),
    GDK_WINDOW_TYPE_HINT_NORMAL);
#endif

...如果您已经显示对话框,使用它为它工作:

...and if you have shown the dialog already, you need to use this for it to work:

#ifdef __WXGTK__
gdk_window_set_type_hint(
    iShouldBeUsingQtDialog->GetHandle()->window,
    GDK_WINDOW_TYPE_HINT_NORMAL);
#endif

这两种情况都需要您在源代码中添加一个包含文件: / p>

Both cases will require you to add an include file into your source:

#ifdef __WXGTK__
#include "gtk/gtkwindow.h"
#endif

...您必须更新您的版本才能找到GTK包含。在G ++的命令行上我试过这个和它工作:

...and you'll have to update your build to find the GTK includes. On the command line for G++ I tried this and it worked:

`pkg-config --cflags --libs gtk+-2.0`

如何 ? :)

这篇关于无模式,无父wxDialog在z顺序中总是高于wxFrame窗口吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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