Get Windows taskbar height
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Veronica Taurino
el 24 de Mzo. de 2021
Respondida: Jan
el 24 de Mzo. de 2021
Hello! I can't get the correct Windows taskbar height by code. I need it for the define the height of my app (app design).
I get the right value only with the following, but I don't like the need to create an empty figure just for the purpose, it is not neat:
h = figure('Menu','none','ToolBar','none','WindowState','maximized','Visible','on');
pause(1)
P2 = get(h,'Position');
P2(2)
close(h);
ans =
41 % correct value! Perfect result using this
Moreover, the previous does not work setting Visible = 'off', it does not update the maximized sizes.
I read this : Finding the height of windows taskbar - MATLAB Answers - MATLAB Central (mathworks.com)
but it does not work:
toolkit = java.awt.Toolkit.getDefaultToolkit();
scr_size = toolkit.getScreenSize();
fprintf('Screen size is: %d x %d\n', scr_size.width, scr_size.height)
jframe = javax.swing.JFrame;
insets = toolkit.getScreenInsets(jframe.getGraphicsConfiguration());
fprintf('Windows task bar height is: %d\n', insets.bottom)
>>>> Screen size is: 2880 x 1620
>>>> Windows task bar height is: 60 % WRONG
what can I do? Thank you
For the app size, I use:
screenSize = get(groot,'ScreenSize');
screenWidth = screenSize(3);
screenHeight = screenSize(4);
left = screenWidth;
bottom = P2(2);
width = screenWidth*0.20;
height = (screenHeight-P2(2))*0.97;
drawnow;
app.MyApp.Position = [left bottom width height];
0 comentarios
Respuesta aceptada
Jan
el 24 de Mzo. de 2021
You can move the taskbar to the side and to the top, hide it dynamically and change the size. The static determination of the height is not reliable.
You can use FEX: WindowAPI to determine the sizes of the monitors with and without task bar. The the problem remains the same: If the taskbar is dynamically faded or moved, the GUI has to be adjusted.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!