How to put a figure window in the center of the screen?

113 vues (au cours des 30 derniers jours)
Merse Gaspar
Merse Gaspar le 27 Mai 2023
Commenté : Merse Gaspar le 28 Mai 2023
Is it possible to put a figure (for example a GUI window) in the center of the screen? How to get screen size in pixels, or how to measure position not from the bottom, but from the top?

Réponse acceptée

Atsushi Ueno
Atsushi Ueno le 27 Mai 2023
width = 640; height = 480;
Pix_SS = get(0,'screensize')
Pix_SS = 1×4
1 1 1920 1200
[(Pix_SS(3)-width)/2 (Pix_SS(4)-height)/2 width height]
ans = 1×4
640 360 640 480
figure('Position', [(Pix_SS(3)-width)/2 (Pix_SS(4)-height)/2 width height])
  3 commentaires
Merse Gaspar
Merse Gaspar le 28 Mai 2023
Thanx!

Connectez-vous pour commenter.

Plus de réponses (1)

Adam Danz
Adam Danz le 27 Mai 2023
> Is it possible to put a figure (for example a GUI window) in the center of the screen? |
movegui('center')
or
movegui(fig,'center')
where fig is a figure handle.

Catégories

En savoir plus sur Graphics Object Properties dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by