フィルターのクリア

How to position a GUI window the same place and size where it was closed?

1 回表示 (過去 30 日間)
Csaba
Csaba 2017 年 12 月 1 日
コメント済み: Greg 2017 年 12 月 14 日
Running the GUI every user puts the GUI window to different places, as it is convenient for them (especially if they have several screens). But it opens at the same place all the time. Is it possible to position the GUI window the same place where it was closed? Also the size would be useful to keep.

採用された回答

Greg
Greg 2017 年 12 月 5 日
編集済み: Greg 2017 年 12 月 10 日
In the GUI's close or delete function:
% Documentation seems to indicate you *have* to call addpref before setpref
% the first time, but my experience says not
setpref('MyGUIName','DefaultPosition',handles.figMyGUI.Position);
EDIT: In the GUI's OutputFcn: Original text: Then in the GUI's opening function:
if ispref('MyGUIName','DefaultPosition')
guipos = getpref('MyGUIName','DefaultPosition');
handles.figMyGUI.Position = guipos;
end
These preferences should be user-specific, so shared machines shouldn't cause problems. You could add a questdlg in the close/delete function to ask if they want the position stored for next time.
  5 件のコメント
Csaba
Csaba 2017 年 12 月 13 日
Updated works perfectly. Thank you!
Greg
Greg 2017 年 12 月 14 日
Always happy to help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by