File Exchange

image thumbnail

maximize figure windows

version 1.0 (4.23 KB) by

Maximize figure windows by using the Microsoft Windows application programming interface (API).

4.38235
35 Ratings

23 Downloads

Updated

No License

Unzip the files and change the the "Current Directory" in MATLAB. Afterwards you can use the function "maximize.m". This function does the same as pressing the "maximize" button on the top right of the window. When you press the "maximize" button after using this function, the figure window will restore to its previous size.
The function is specific to Mircosoft Windows.

Examples:

maximize the current figure
----------------------------
maximize;

maximize the current figure
----------------------------
maximize(gcf);

maximize the specified figure
------------------------------
h = figure;
maximize(h);

maximize the application window
--------------------------------
maximize(0);

maximize more than one figure
------------------------------
h(1) = figure;
h(2) = figure;
maximize(h);

maximize all figures
---------------------
maximize('all');

maximize a GUI in the OpeningFcn
---------------------------------

% --- Executes just before untitled is made visible.
function untitled_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 untitled (see VARARGIN)

% Choose default command line output for untitled
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% maximize the GUI
set(hObject,'Visible','on');
maximize(hObject);

Comments and Ratings (56)

wlbcyy

wlbcyy (view profile)

In the under comments,Shio Williams' Work at 2010 is good!!!
Thx @Shio Williams

Alberto Lega

64 bit support needed.

64 bit support needed

Roman Voronov

64 bit support needed

Martin V.

Martin V. (view profile)

Thanks for very useful function.

Shahar

Shahar (view profile)

Very useful!

I encounter a slight problem when using the function within a matlab GUI.
Adding "maximize(handles.figure1);" at the end of the mygui_OpeningFcn() function doesn't maximize the window as expected.

Did anyone encountered this problem before? How can I use the maximize function to enlarge the GUI at start?

Shahar

Shahar (view profile)

hailiang shen

Not sure since which matlab version the following will work, but with version R2011a, you may use a one line code:

set(gcf, 'Position', get(0,'ScreenSize'));

Atcold

Atcold (view profile)

Could be possible to have a version for 64 bit please? I don't have any compiler installed within Matlab..
Many thanks indeed

Atcold

Atcold (view profile)

And thanks also to Joseph! (:

Joseph

Joseph (view profile)

To suppress the warning:
warning('off', 'MATLAB:mex:deprecatedExtension');

to supress it only temporarily
s = warning('off', 'MATLAB:mex:deprecatedExtension');
maximize(hFigure)
warning(s);

Thanks!

Joseph

Joseph (view profile)

Thanks, This is great, but like Andy was asking, is there a way to suppress the dll warning?

vick Audi

Nicolas

>> figure
>> hFig = gcf;
>> jFig = get(handle(hFig), 'JavaFrame');
>> jFig.setMaximized(true);

Michal Krejci

I have problem with maximizing GUI, when I put this:
% maximize the GUI
set(hObject,'Visible','on');
maximize(hObject);
on the end of OpeningFcn everything seems fine and window is maximized, but then function gui_mainfcn ruined everithing with this code:

gui_hFigure = local_openfig(gui_State.gui_Name, 'reuse',gui_Visible);

(Matlab R2009a)
Any solutions?

Greg Elphick

I too find this fantastic, but am looking for a 64 bit version - any solutions here?

Andy

Andy (view profile)

whenever I run this, I get a warning about running MEX-files with .dll extensions. (I am running 2009b), just wondering if an update to get around this be possible?

Warning below:
"MEX-files with .dll extensions will not execute in a future version of MATLAB."

Nicholas

Does anyone have a copy of the c-file for 64 bit windows they could send me? I'd appreciate it.

zhou

zhou (view profile)

is here any linux version? thx

Shio Williams

here's a cool little work around. you need to know your figure window name, if you don't want to name it, you can simply name it temporarily using the set(hFig, 'Name', 'Figure X');

    %Make it Full Screen
   
    h = actxserver('WScript.Shell');
%Put the title of your window as seen in the title bar
    h.AppActivate('Figure X');
    h.SendKeys('% '); %this is shortcut key ALT + {SPACE}
    h.SendKeys('{DOWN 4}');
    h.SendKeys('~'); %This is enter

Rashed

Rashed (view profile)

Thanks a lot.

Martin Tettke

You need to compile the c-file for win64.
If anyone need a compiled version, drop me a note.

Alexander

As you can see from the post I sent 09/08 I was very happy with the application. I am now attempting to use the code in Windows 2003, 64bit edition and getting the same problem Jorg, Yasser and Alain had. Any suggestions other than using a different OS?

Thanks

@Yasser, Alain Trostel

I have the same problem (I did have the .dll file in the same folder as my .m file, but ??? Undefined function or method 'windowMaximize' for input arguments of type 'char'. )

I think it may be because I'm using WinXP64 bit with Matlab 64bit version. Probably the dll is not compatible with that...

I hope someone will make a 64bit version available and post it here.

 

Yasser

Yasser (view profile)

John McArthur,

I did have the .dll file in the same folder as my .m file. Any idea why it wouldn't pick it up?

Johnny8088

I am really appreciated for this post. It works great.

works perfect on R14, WindowsXP, with taskbar set to autohide. need to have the .dll file either in the folder with the .m file, or in your searchpath

Yasser

Yasser (view profile)

I get this error:

??? Undefined function or method 'windowMaximize' for input arguments of type 'char'.

Error in ==> maximize at 149
        windowMaximize(windowname,get(h(n),'Resize'));

Error in ==> Characterizing_Devices at 111
    maximize('all');

Why isn't it picking up the dll file?

Thanks!

Alex Orbell

Vey useful, does exactly what it says on the tin, make sure you download all three files though!

ram ram

Great post.. It is useful

Nick Steinmetz

So much better than the other hacks involving the 'Position' property of the window - those just make it fill the window (sometimes more or less completely) while this function literally does the same thing as clicking maximize yourself. Thanks, Alain!

Miroslav Pajic

thanks!!!

Niels Scheffer

thanks a lot!
I was really annoyed by double clicking for maximizing and the get('Screensize') set-thing doesn't work for me (if it comes to beauty)

Tim Scribner

Works as indicated

Jeff Jackson

Works as expected. :-)

François Mourougaya

Works nicely.

chris lee

works perfectly on 7.4.0.287 (R2007a)!

thanks Alain

Khalid Aamir

It does not work at all.

Matt Strasser

I can't thank you enough for this. By the way even though it says it was designed for R13, it works brilliantly in 2006a.

Alain Trostel

I think there is no way to set the default factory settings, sorry.

Laurentiu B

nice stuff, is there a way to set the default factory settings to make all new figures maximized from the start?

Jörg Buchholz

You saved my day! Thanks alot...

Scott Miller

Seems to work pretty well, although when I fired it up for the first time and unlocked my taskbar, windows IE locked up and I had to kill it with the taskmanager. It hasn't done that since (nor have I tried unlocking the taskbar since).

Scott Miller

Jaime Matas

Great! I've been looking for the way to maximize a figure in MATLAB a lot of time... and it's really possible!!

David Scraggs

cm jones

First time using code from this author. Really impressive. The code is absolutely "clean" and WELL documented.

Great job. (Would've taken me forever to write it.)

Busa-Fekete Robert

Stefan Eicher

Super sach. tschö

Marcel Matthey-Doret

as usual the source code is well documented. i've been looking a long time for such a function and i was never able to develop it by myself. thanks a lot...

Alain Trostel

The zipped folder is not updated yet, only the description. MathWorks will solve this problem.

Duane Hanselman

Note that a platform independent solution (using Java calls) already exists. See file #9523. I know that I always prefer a platform independent solution. I am not a Java person, so that is why I wrote "maxfigsize" as a poor man's alternative.

John D'Errico

If it has different functionality from an existing tool, then I'd recommend stating that in the description. I will note that this tool is of course specific to Windows. This should be listed in the requirements, as well as the statement in the summary line. So while maxfigsize [FEX 3036] works on any platform, maximize is platform specific. This is important for installations that support multiple platforms. A friendly touch would be to allow the user to just type "maximize" with no arguments, which would then be equivalent to maximize(gcf). While I can't test the functionality of this code as I use a different OS, the help seems quite reasonable.

Alain Trostel

It's not the same like the function "maxfigsize.m" by Duane Hanselman. After you maximized the figure window with my function, you have the option to restore the figure window by push the middle button on the top right. When you use the function "maxfigsize.m" it doesn't work.

Stefan Gautschi

velo

F Moisy

Idem as maxfigsize by Duane Hanselman, isn't it?

Updates

works also when the window is not resizable

improvement of the code metrics

You can now maximize more than one figure, all figures or the application window

zipped folder was not updated

You can use the function now without an input parameter

MATLAB Release
MATLAB 6.5 (R13)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video