Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bring MATLAB Window To Front

591 views
Skip to first unread message

Dustin Harvey

unread,
Jan 6, 2010, 11:40:21 AM1/6/10
to
Does anyone know of a command or script that will bring MATLAB's window to the front?

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.

Jan Simon

unread,
Jan 6, 2010, 11:49:04 AM1/6/10
to
Dear Dustin!

> 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

Dustin Harvey

unread,
Jan 6, 2010, 12:10:21 PM1/6/10
to
"Jan Simon" <matlab.T...@nMINUSsimon.de> wrote in message <hi2eu0$dik$1...@fred.mathworks.com>...

Jan,

Too much help! :) Both methods do just what I wanted. Now I have to decide which to use!

Thanks,

Dustin

us

unread,
Jan 6, 2010, 12:21:21 PM1/6/10
to
"Dustin Harvey"

> > Matlab command:
> > commandwindow;
> > Or:
> > 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!

well... not - really...

type commandwindow;
% tells you that COMMANDWINDOW
% simply uses the java syntax if the engine is used...

us

Jan Simon

unread,
Jan 6, 2010, 2:59:21 PM1/6/10
to
Dear Dustin!

> > > 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

Steven Lord

unread,
Jan 6, 2010, 3:40:38 PM1/6/10
to

"Jan Simon" <matlab.T...@nMINUSsimon.de> wrote in message
news:hi2q2p$9jb$1...@fred.mathworks.com...

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


Jan Simon

unread,
Jan 6, 2010, 4:13:02 PM1/6/10
to
Dear Steven!

> 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

0 new messages