Open App-Window on same screen as Button in another app was clicked
5 次查看(过去 30 天)
显示 更早的评论
I am working with two monitors. When I start my app it opens on Monitor 1. Then I move it by hand to Monitor 2 an click on a App-Button to open another App-Window. This Window again opens on the Monitor 1.
Is there a possibility to move the second App-Window on Monitor 2? I would like the App to always open on the Monitor on which I am working.
0 个评论
采纳的回答
Harald
2023-11-13
Hi Nico,
there is a default Position property that you can modify. For the purpose of this property, MATLAB treats two monitors as one wide monitor: if the first entry is greater than the horizontal number of pixels, then the figure is on monitor 2.
At least if both monitors have same resolution, the following will move a figure to the sample place on monitor 2:
s = get(0,'screensize');
w = s(3);
f = figure;
f.Position(1) = f.Position(1) + w;
I suppose you need to check the Position of your app window to know on what screen it is, and then adjust the Position of app 2 accordingly if needed.
Best wishes,
Harald
2 个评论
Harald
2023-11-16
Nice approach, thanks for sharing! ... and good to see that movegui is smart enough to move to the center of the current screen. :)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!