3

Is there a way to create a GUI which starts as a maximized windows? I've tried to add set(gcf,'Units','normalized','Position',[0,0,1,1]); at the end of my gui's mygui_OpeningFcn() function but the GUI is not maximized properly (see printscreen).

Setting the GUI properties at GUIDE to Units-'normalized' and Position-[0,0,1,1] didn't help either.

I've also tried to use the Matlab File Exchange maximize function by adding maximize(handle.figure1); at the end of my gui's mygui_OpeningFcn() but it doesn't work either (same visual result - a GUI which is not entirely maximized).

Is there a way to make the Matlab GUI appear as a maximized figure when I launch it? Why am I getting this strange visual behavior of the GUI?

GUI not maximized properly

Amro
  • 123,847
  • 25
  • 243
  • 454
shahar_m
  • 3,461
  • 5
  • 41
  • 61
  • set(gcf, 'Position', get(0,'Screensize')); – kol May 29 '12 at 11:22
  • set(gcf,'Units','normalized','Position',[0,0,1,1]); – kol May 29 '12 at 11:24
  • 1
    if you use guide make sure your gui is resizeable. If it's complicated you will need to write your own resize function. – bdecaf May 29 '12 at 11:53
  • @kol - I've tried both ways and I get the exact same result as with the `maximize` function, a non maximized figure (see image). – shahar_m May 29 '12 at 12:00
  • @bdecaf - I've changed the GUI resize behavior to "proportional" via the "GUI options" and also change it to "other (use ResizeFcn)", but the result is the same. Maybe I can't maximize a GUI from the openingFcn within the GUI itself? – shahar_m May 29 '12 at 12:06
  • if I recall correctly there might be a resize property for every element. Did you check for your textbox? (i think the coordinates should then be `relative`) – bdecaf May 29 '12 at 12:13
  • @bdecaf - There's no resize property for the listbox I use within the GUI. When I run the GUI without any uicontrol in it I get the same result, a non maximized GUI. – shahar_m May 29 '12 at 13:22
  • 2
    Try this: f = get(gcf,'JavaFrame'); f.setMaximized(true); – kol May 30 '12 at 07:24
  • Ok - wrong words, I checked. Set the `Units` of the listbox to `normalized`. – bdecaf May 30 '12 at 08:24

1 Answers1

1

If you are on a Windows machine, I suggest you use the WindowAPI submission from FEX. It directly calls Windows API functions (using a MEX file), thus allowing far more advanced control of figures than just minimize and maximize:

hFig = figure('Menubar','none');
WindowAPI(hFig,'Maximize')
Amro
  • 123,847
  • 25
  • 243
  • 454