简体   繁体   English

从Motif中的BulletinBoard小部件中删除关闭按钮

[英]Remove close button from BulletinBoard widget in Motif

Is it possible to remove the close button from a BulletinBoard widget in Motif? 是否可以从Motif中的BulletinBoard小部件中删除关闭按钮? Or, alternatively, attach a callback function to it? 或者,可以附加一个回调函数吗? I know I can do this for the toplevel widget but can't seem to do it for a BulletinBoard. 我知道我可以为顶级窗口小部件执行此操作,但似乎无法为BulletinBoard执行此操作。

For the toplevel shell I can do this to attach a callback function to the close button: 对于顶级外壳,我可以执行以下操作将回调函数附加到关闭按钮:

XmAddWMProtocolCallback(toplevel, XmInternAtom(display,"WM_DELETE_WINDOW",True),
        (XtCallbackProc)buttonCB, (XtPointer)data);

Or I can remove it entirely with this: 或者,我可以完全删除它:

XtVaSetValues(toplevel, XmNmwmFunctions, MWM_FUNC_ALL | MWM_FUNC_CLOSE, NULL);

But neither of these work for a BulletinBoard widget. 但是这些都不适用于BulletinBoard小部件。 The latter has no effect. 后者无效。 The former gives an error, "Warning: Widget must be a VendorShell." 前者给出一个错误,“警告:窗口小部件必须是VendorShell。”

I found a way to do this already. 我已经找到了一种方法。 Instead of using XtVaSetValues, I found I can use XtSetArg(myBB, ...) at the time the BB widget is created. 我发现可以在创建BB小部件时使用XtSetArg(myBB,...),而不是使用XtVaSetValues。 In other words, 换一种说法,

n=0;
XtSetArg(args[n], XmNheight, 300); n++;
XtSetArg(args[n], XmNwidth,  300); n++;
// ...etc...
XtSetArg(args[n], XmNmwmFunctions, MWM_FUNC_ALL|MWM_FUNC_CLOSE); n++;  // <--- answer
myBB = XmCreateBulletinBoardDialog(parent, "myBB", args, n);

An XmBulletinBoard widget does not have a close button. XmBulletinBoard小部件没有关闭按钮。 You are calling XmCreateBulletinBoardDialog, which creates an XmDialogShell with an XmBulletinBoard as its child. 您正在调用XmCreateBulletinBoardDialog,它将创建一个XmDialogShell,并将XmBulletinBoard作为其子级。

Your attempt to remove the dialog's close button is incorrect. 您尝试删除对话框的关闭按钮的尝试不正确。

You should use 你应该用

MWM_FUNC_ALL | MWM_FUNC_RESIZE | MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE

But it is much better to tie the close button to your own method as you tries, except you are adding the protocol callback to the wrong widget - you need it on the DialogShell, not the BulletinBoard. 但是最好在尝试时将关闭按钮绑定到您自己的方法上,除非您将协议回调添加到错误的小部件上-您需要在DialogShell而不是BulletinBoard上使用它。 So use XtParent(myBB). 因此,请使用XtParent(myBB)。

As an aside, you should not cast buttonCB in your call; 顺便说一句,您不应在通话中投放buttonCB; if the compiler is complaining without the cast, your buttonCB function does not have the correct signature. 如果编译器抱怨没有强制转换,则您的buttonCB函数没有正确的签名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM