I am developing a java-based interface that occasionally refers the user to sections of the MATLAB window (specifically current directory and variable editor). Instead of telling the user to "See MATLAB," I would prefer MATLAB's window to move to the foreground.
I could move my Java application to the back, but that only creates the same behavior if no other windows are open.
> Does anyone know of a command or script that will bring MATLAB's window to the front?
Matlab command:
commandwindow;
Or:
mainFrame = com.mathworks.mde.desk.MLDesktop.getInstance.getMainFrame;
mainFrame.toFront;
Good luck, Jan
Jan,
Too much help! :) Both methods do just what I wanted. Now I have to decide which to use!
Thanks,
Dustin
well... not - really...
type commandwindow;
% tells you that COMMANDWINDOW
% simply uses the java syntax if the engine is used...
us
> > > mainFrame = com.mathworks.mde.desk.MLDesktop.getInstance.getMainFrame;
> > > mainFrame.toFront;
> > Too much help! :) Both methods do just what I wanted. Now I have to decide which to use!
Unfortuanely I cannot offer a 3rd method, because I haven't solved this yet:
Under Windows a MEX can call SetWindowPos with the HWND_TOPMOST flag. But I need the handle of Matlab's command window for this case - not 0, but the operating system's handle. I can get it using the above java calls, but if I have to call java, I can use it for the whole solution.
Getting the OS handle of other figures is solved several times in the FEX (maxfig, ShowWindow, AlterWindow, setWindowState, winOnTop). I'm using the different approach of setting the window title temporarily to a unique magic string to avoid the problem of multiple Matlab figures having the same name.
But I cannot change the title of the command window from inside a MEX. Any ideas?!
Kind regards, Jan
Why not just use mexCallMATLAB to execute "commandwindow" to bring the
Command Window to the front?
--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> Why not just use mexCallMATLAB to execute "commandwindow" to bring the
> Command Window to the front?
Because I thought of the TOPMOST feature, which lifts the window even on top of other programs.
But you give me a 2nd chance to offer 2 independent solutions for the OP:
uimenufcn(0, 'WindowCommandWindow');
Thanks and good luck, Jan