设置 Motif 窗口的标题 [英] Setting the title of a Motif Window
问题描述
我正在尝试设置顶级 Motif 2.1 窗口的标题.
I am trying to set the title of a toplevel Motif 2.1 window.
从 O'Reilly 第六卷 A 中,我看到在 Motif 2.1 中建议 XtVaOpenApplication
创建顶级 Widget.
From O'Reilly Volume Six A, I have seen that in Motif 2.1 XtVaOpenApplication
is recommended to create a toplevel Widget.
在本附录中,它可以了解如何使用 options
和 XtNumber(options)
通过参数列表对资源进行操作.
In this appendix it can be seen how options
and XtNumber(options)
are used to act on resources via argument list.
我尝试在调用程序时使用它来生成可选标志 -title WINDOW_TITLE
,但没有成功.
I have tried to use it to generate an optional flag -title WINDOW_TITLE
while invoking the program, without sucess.
这是我尝试过的:
#include <stdlib.h>
#include <stdio.h>
#include <Xm/Xm.h>
#include <Xm/PushB.h>
static XrmOptionDescRec options[] = {
{ "-title", "XmNtitle", XrmoptionIsArg, NULL },
};
int main(int argc, char *argv[]) {
Widget toplevel; /* Top Level Button */
XtAppContext app; /* Application Context */
char *window_title = NULL; /* Top Level Window Title */
/* INITIALIZE TOP LEVEL WINDOW */
XtSetLanguageProc(NULL, NULL, NULL);
toplevel = XtVaOpenApplication( &app, argv[0], options, XtNumber(options), &argc, argv, NULL, sessionShellWidgetClass, NULL);
/* REALIZE TOPLEVEL WINDOW AND LAUNCH APPLICATION LOOP */
XtRealizeWidget(toplevel);
XtAppMainLoop(app);
return 0;
}
程序可以编译,但对 -title MYTITLE
命令行参数没有反应.
The program compiles but it does not react to -title MYTITLE
command line argument.
这是 makefile
(适用于 FreeBSD 12):
This is the makefile
(works on FreeBSD 12):
test: test.o
cc -L/usr/local/lib -O -o test test.o -lXm -lXt -lX11
test.o: test.c
cc -I/usr/local/include -c test.c
如何根据名为 -title
的可选参数更改窗口的标题?
How can I change the title of the window based on an optional argument named -title
?
推荐答案
正确的 xrm 选项行是
The correct xrm option line is
{"-title", ".title", XrmoptionSepArg, NULL}
您实际上不需要指定它,因为它在默认的 Xt 选项表中.
You don't actually need to specify it because it is in the default Xt option table.
通常在指定 xrm 资源名称时省略 XmN
.
In general you omit XmN
when specifying xrm resource names.
这篇关于设置 Motif 窗口的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!