当用户单击motif窗口(小部件)的关闭框时,如何拦截,以及如何防止Motif窗口管理器在被单击的关闭框上关闭整个调用应用程序(以便我的应用程序可以关闭Motif应用程序上下文和窗口并继续运行)?我试着用Google,tuts和docs找出答案,但是没有成功。需要C++。
发布于 2009-09-07 14:54:44
这似乎是有效的(可以在inet上找到):
#include <Xm/Protocols.h>
Boolean SetCloseCallBack (Widget shell, void (*callback) (Widget, XtPointer, XtPointer))
{
extern Atom XmInternAtom (Display *, char *, Boolean);
if (!shell)
return False;
Display* disp = XtDisplay (shell);
if (!disp)
return False;
// Retrieve Window Manager Protocol Property
Atom prop = XmInternAtom (disp, const_cast<char*>("WM_PROTOCOLS"), False);
if (!prop)
return False;
// Retrieve Window Manager Delete Window Property
Atom prot = XmInternAtom (disp, const_cast<char*>("WM_DELETE_WINDOW"), True);
if (!prot)
return False;
// Ensure that Shell has the Delete Window Property
// NB: Necessary since some Window managers are not
// Fully XWM Compilant (olwm for instance is not)
XmAddProtocols (shell, prop, &prot, 1);
// Now add our callback into the Protocol Callback List
XmAddProtocolCallback (shell, prop, prot, callback, NULL);
return True;
}设置这样的回调将防止应用程序由于被处理的close事件而被关闭,这是默认的事件处理程序。
发布于 2012-07-31 01:22:00
vendorShellWidgetClass不会为你做这个戏法吗?就像在中一样,只关闭了motif应用程序上下文,而不是窗口。
发布于 2009-09-07 13:30:59
在X11上,当你点击一个窗口的关闭框时,窗口管理器会向你的应用程序发送一个信号,告诉它退出。无论您使用的是motif、gtk还是Qt,都无关紧要,因为关闭框属于WM,而不是您的应用程序。
您需要捕获unix信号以防止应用程序关闭。
https://stackoverflow.com/questions/1389414
复制相似问题