Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
gui 2007b maximaize window

Subject: gui 2007b maximaize window

From: german

Date: 2 Feb, 2008 09:27:01

Message: 1 of 8

hi
I recently upgraded to 2007b
I used the function maximize.m (file exchange)
to maximize the main gui window when it opens.
now it is not working anymore.
I also have problems with windows that should open in front
are now sent backwards.
any ideas?
thanks

Subject: gui 2007b maximaize window

From: Vihang Patil

Date: 4 Feb, 2008 08:07:04

Message: 2 of 8

"german " <nospam@yahoo.com> wrote in message <fo1d15$9b3
$1@fred.mathworks.com>...
> hi
> I recently upgraded to 2007b
> I used the function maximize.m (file exchange)
> to maximize the main gui window when it opens.
> now it is not working anymore.
> I also have problems with windows that should open in
front
> are now sent backwards.
> any ideas?
> thanks


Hello
You can use this Java hack
h = figure;drawnow;
j = get(h,'javaframe');
jfig = j.fFigureClient.getWindow; %undocumented
jfig.setAlwaysOnTop(1);%places window on top, 0 to disable
jfig.setMaximized(1); %maximizes the window, 0 to minimize

HTH
Vihang

Subject: gui 2007b maximaize window

From: ImageAnalyst

Date: 5 Feb, 2008 18:37:03

Message: 3 of 8

On Feb 4, 3:07=A0am, "Vihang Patil" <vihang_pa...@yahoo.com> wrote:
> "german " <nos...@yahoo.com> wrote in message <fo1d15$9b3
>
> $...@fred.mathworks.com>...
>
> > hi
> > I recently upgraded to 2007b
> > I used the function maximize.m (file exchange)
> > to maximize the main gui window when it opens.
> > now it is not working anymore.
> > I also have problems with windows that should open in
> front
> > are now sent backwards.
> > any ideas?
> > thanks
>
> Hello
> You can use this Java hack
> h =3D figure;drawnow;
> j =3D get(h,'javaframe');
> jfig =3D j.fFigureClient.getWindow; %undocumented
> jfig.setAlwaysOnTop(1);%places window on top, 0 to disable
> jfig.setMaximized(1); %maximizes the window, 0 to minimize
>
> HTH
> Vihang

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
This doesn't exactly work if you're using GUIDE. I put this code into
my m file. The main window in GUIDE is called figMain. The macro is
called MyMacro (I changed the actual name).

% --- Executes just before MyMacro is made visible.
function MyMacro_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to MyMacro (see VARARGIN)

% Choose default command line output for MyMacro
handles.output =3D hObject;

%=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
% --- My Startup Code
--------------------------------------------------
    % Clear old stuff from console.
     clc;
h =3D handles.figMain;
drawnow;
j =3D get(h,'javaframe');
jfig =3D j.fFigureClient.getWindow; %undocumented
jfig.setAlwaysOnTop(1);%places window on top, 0 to disable
jfig.setMaximized(1); %maximizes the window, 0 to minimize
    % Update handles structure
    guidata(hObject, handles);

% --- End of My Startup Code
--------------------------------------------------


Now, when it hits the jfig.setMaximized line, it does indeed maximize
the window, but then it continues on doing guidata(hObject, handles);
plus a bunch of other hidden MATLAB stuff before it actually turns
control of the window over to the user. Somewhere in that, it un-
maximizes the window. Nice try though. I'd still like a solution.
Regards,
ImageAnalyst

Subject: gui 2007b maximaize window

From: Vihang Patil

Date: 7 Feb, 2008 04:25:04

Message: 4 of 8

Hello
You can use my code in a separate m file as follows, to make
it work
ex:
%supposes guimain.m is your main gui figure(application)
window. Then make gui_tocall_main.m as a new m file that
calls your guimain function, with following to make it work

function gui_tocall_main
h = guimain;drawnow;
pause(1);
j = get(h,'javaframe');
jfig = j.fFigureClient.getWindow; %undocumented
jfig.setAlwaysOnTop(1);%places window on top, 0 to disable
jfig.setMaximized(1); %maximizes the window, 0 to minimize




HTH
Vihang

Subject: gui 2007b maximaize window

From: Stephan Hoffmann

Date: 7 Feb, 2008 07:42:05

Message: 5 of 8

The figure has to be visible. Otherwise this hint doesnt
work.

Subject: gui 2007b maximaize window

From: ImageAnalyst

Date: 7 Feb, 2008 18:09:12

Message: 6 of 8

On Feb 7, 2:42=A0am, "Stephan Hoffmann"
<stephan.limitedhoffmann.KEINS...@de.bosch.com> wrote:
> The figure has to be visible. Otherwise this hint doesnt
> work.

Stephen:
The figure is/was visible. It showed up when the drawnow command was
executed. And your code maximized the window. The problem is that
there's additional code that gets executed when you're running a GUIDE-
associated m file that gets executed that UNMAXIMIZES the window. So
basically it undoes what your code did, and I don't know of any way
around it.
Thanks,
ImageAnalyst

Subject: gui 2007b maximaize window

From: Bruno Luong

Date: 7 Feb, 2008 18:16:02

Message: 7 of 8

Hi, I'm not sure what is the problem. I have just tested
maximize on 2007b gui main figure, and it works to me.

Bruno

Subject: gui 2007b maximaize window

From: Stephan Hoffmann

Date: 8 Feb, 2008 11:13:06

Message: 8 of 8

ImageAnalyst <imageanalyst@mailinator.com> wrote in message
<df7f28e2-0087-4c8a-bd52-
c9e2b7547f10@i7g2000prf.googlegroups.com>...
> On Feb 7, 2:42=A0am, "Stephan Hoffmann"
> <stephan.limitedhoffmann.KEINS...@de.bosch.com> wrote:
> > The figure has to be visible. Otherwise this hint doesnt
> > work.
>
> Stephen:
> The figure is/was visible. It showed up when the drawnow
command was
> executed. And your code maximized the window. The
problem is that
> there's additional code that gets executed when you're
running a GUIDE-
> associated m file that gets executed that UNMAXIMIZES the
window. So
> basically it undoes what your code did, and I don't know
of any way
> around it.
> Thanks,
> ImageAnalyst

If you want to maximize a gui created by guide, you have to
maximize your gui after the gui is loaded completely.
e.g. by a extra m-file which starts your gui:

h=mygui;
j=get(h,'JavaFrame');
set(j,'Maximized',true);

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us