有没有办法改变 MATLAB 命令行窗口的标题?

发布于 2024-08-16 03:36:26 字数 220 浏览 7 评论 0原文

我正在使用 C++ API 来启动 MATLAB(通过 engOpenSingleUse)。一切正常。但我想将窗口的标题从“MATLAB Command Window”更改为其他内容。

我经常打开其中 4 到 5 个,如果我的程序崩溃,偶尔会打开其中一个。如果我可以改变标题,我就能更好地知道哪个是哪个。

是否有我可以执行(通过 engEvalString)的 MATLAB 命令来执行此操作?

I'm using the C++ API to fire up MATLAB (via engOpenSingleUse). Everything's working fine. But I'd like to change the title of the window from "MATLAB Command Window" to something else.

I often have 4 or 5 of them open, and occasionally one gets orphaned if my program crashes. If I could change the title, I'd have a better shot of knowing which one was which.

Is there a MATLAB command I could execute (via engEvalString) that would do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

东北女汉子 2024-08-23 03:36:26

对于 Matlab 7:

jDesktop = com.mathworks.mde.desk.MLDesktop.getInstance;
jDesktop.getMainFrame.setTitle('my new title');

*或专门用于命令行窗口:

cmdWin = jDesktop.getClient('Command Window');
cmdWin.getTopLevelAncestor.setTitle('my new title');

对于 Matlab 6:

jDesktop = com.mathworks.ide.desktop.MLDesktop.getMLDesktop;
jDesktop.getMainFrame.setTitle('my new title');

*或对于命令行窗口:

cmdWin = jDesktop.getClient('Command Window');
cmdWin.getTopLevelWindow.setTitle('my new title');

其他相关的未记录的桌面功能描述如下:
http://UndocumentedMatlab.com/blog/tag/desktop/

For Matlab 7:

jDesktop = com.mathworks.mde.desk.MLDesktop.getInstance;
jDesktop.getMainFrame.setTitle('my new title');

*or specifically for the Command Window:

cmdWin = jDesktop.getClient('Command Window');
cmdWin.getTopLevelAncestor.setTitle('my new title');

For Matlab 6:

jDesktop = com.mathworks.ide.desktop.MLDesktop.getMLDesktop;
jDesktop.getMainFrame.setTitle('my new title');

*or for the Command Window:

cmdWin = jDesktop.getClient('Command Window');
cmdWin.getTopLevelWindow.setTitle('my new title');

Other related undocumented desktop features are described here:
http://UndocumentedMatlab.com/blog/tag/desktop/

黑凤梨 2024-08-23 03:36:26

尝试直接针对 Java AWT 类进行编码。这可能更灵活,并且可以在 C++ 下运行的 Matlab 引擎内工作。 (还没有在这种情况下测试它,因为我不使用该引擎。)

function change_win_title(oldName, newName)

wins = java.awt.Window.getOwnerlessWindows();
for i = 1:numel(wins)
    if isequal(char(wins(i).getTitle()), oldName)
        wins(i).setTitle(newName);
    end
end

你可以像这样使用它。

change_win_title('MATLAB Command Window', 'My new window name')

您可以使用其他测试(窗口类等)来识别感兴趣的窗口。

Try coding directly against the Java AWT classes. This may be more flexible and work inside the Matlab engine running under C++. (Haven't tested it in that context, since I don't use the engine.)

function change_win_title(oldName, newName)

wins = java.awt.Window.getOwnerlessWindows();
for i = 1:numel(wins)
    if isequal(char(wins(i).getTitle()), oldName)
        wins(i).setTitle(newName);
    end
end

You'd use it like this.

change_win_title('MATLAB Command Window', 'My new window name')

You can use other tests (window class, etc) to identify the windows of interest.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文