フィルターのクリア

Windows taskbar height in normalised units

2 ビュー (過去 30 日間)
Boris Sorokin
Boris Sorokin 2020 年 7 月 3 日
回答済み: Monisha Nalluru 2020 年 7 月 6 日
I'd like to get the windows taskbar height in normalised units. To this end I create a new figure, maximise it and get its position:
set(groot,'defaultFigureUnits','normalized') % set default units to normalised
figure('WindowState','maximized') % create a maximised window
pos = get(gcf,'OuterPosition') % get the outer position of the window
close all
Running this 4 commands one by one in the command window gives the correct answer:
pos =
-0.0047 0.0403 1.0094 0.9681
While running them all together in the command window or as a part of the script gives:
pos =
450.9953 299.9917 560.0094 420.0444
So matlab gives me the position in pixels instead of normalised units. I don't understand why, please help me.

採用された回答

Monisha Nalluru
Monisha Nalluru 2020 年 7 月 6 日
The difference in solutions is due to the following reason
  • MATLAB calculates the original position faster than the figure to maximize.
  • So, you can include ‘pause’ to ensure that the maximized position is calculated. The period of pause needs to be more for older version systems.
f=figure('WindowState','maximized','Units','normalized'); % maximized screen and units are normalized
pause(1); % delay the constructing recommended figure
position=f.Position; % to get the positions of figure
You can refer this link

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by