Setting the GUI window always at center

Hi
I am trouble with setting my GUI window at the center of the computer screen whenever i click on the 'run' button to start the program. May I know is there a easy way to preset it in the OpeningFcn of the code?

 採用された回答

Sean de Wolski
Sean de Wolski 2013 年 3 月 28 日

6 投票

doc movegui
And:
movegui(gcf,'center')

5 件のコメント

William
William 2013 年 3 月 28 日
wow thanks a lot!
Image Analyst
Image Analyst 2013 年 3 月 28 日
Sean, can you get that to work with menu()? menu() always shows up in the upper left corner of the screen instead of the middle. I guess it doesn't work because it doesn't run movegui() until menu() is done.
menu('hi', '1', '2', '3');
movegui(gcf,'center') % doesn't work.
How do you center menu()?
Sean de Wolski
Sean de Wolski 2013 年 3 月 28 日
@IA, the problem with menu() is line 228 and line 268. Line 228 specifies the position and line 268 force command execution to stop until you select something.
I would suggest writing your own class or function that does the same thing as menu without the positioning.
And of course you can always submit an enhancement request :)
JZH
JZH 2018 年 1 月 4 日
hey Sean, I got the following error, and it seems like movegui doesn't support GUI designed in app designer?
movegui(app.ELD_GUI, 'center') Error using matlab.ui.Figure/set Functionality not supported with figures created with the uifigure function. For more information, see Graphics Support in App Designer. Error in movegui (line 278) set(fig, 'OuterPosition', newpos);
Jessa Juarez
Jessa Juarez 2021 年 10 月 21 日
Hi @JZH, I used movegui(app.UIFigure, 'center') and it worked for app designer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

質問済み:

2013 年 3 月 28 日

コメント済み:

2021 年 10 月 21 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by