Problems with a resize function callback
Ältere Kommentare anzeigen
Hi,
I'm developing a programmed GUI (using the nice GUI toolbox layout available on file exchange). What I want to do is to define minimal length and minimal height of the GUI figure to automatically resize it to avoid displaying problems when the user resize the screen.
To do so, I defined the following resize function callback associated to the figure GUI (I use nested functions, so it is not a variable problem)
function myGUI
mainFig=figure('Position',[139 122 1204 675]);
set(mainFig,'ResizeFcn',@Resize_clbk);
min_length=1200;
min_heigth=600;
%[.....]
function Resize_clbk(hObject,Event)
actual_pos=get(hObject,'Position');
if actual_pos(3)<min_length
set(hObject,'Pos',[actual_pos(1:2) min_length actual_pos(4)]);
end
if actual_pos(4)<min_heigth
set(hObject,'Pos',[actual_pos(1:3) min_heigth]);
end
end
end
This function works nice when I resize the figure from both rigth and bottom borders of the window, but it doesn't works any time when I resize the window from the left or top border, or any corner.
Does anyone have a solution ?
Thank's in advance for your help ^^
2 Kommentare
per isakson
am 5 Okt. 2012
With FEX contribution do you refer to?
Julien
am 5 Okt. 2012
Akzeptierte Antwort
Weitere Antworten (1)
Julien
am 6 Okt. 2012
6 Kommentare
Jan
am 6 Okt. 2012
I do not have 2012b for testing this by my own. Please try:
FigH = gcf;
drawnow;
jFrame = get(handle(FigH), 'JavaFrame');
jFrame.setMinimumSize(java.awt.Dimension(200,200));
On one hand this is pure guessing, on the other hand this will not run with "all" Matlab versions. Older Matlab versions require the figure proxy. I assume Yair knows more details.
Julien
am 6 Okt. 2012
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!