MATLAB ResizeFcn Callback Error

I am editing a GUI written in MATLAB and have a line in the opening windowFF that sets a callback to resize the shape.

set(hObject, 'UserData', handles.ParentFig, 'ResizeFcn',@cbFigResize, 'CloseRequestFcn', @Cancel); 

A callback will be inserted below with a lot of changes for simplicity.

 function cbFigResize(src,evt) % check if figure width is less than 600 if fpos(3) < 600 %set min. width to 600 fpos(3) = 600 end %check if figure height is less than 560 if fpos(4) <560 % set minimum height to 560 fpos(4) = 560; end 

My colleague is launching Windows XP and an earlier version of MATLAB. I am running Windows 7 and MATLAB 7.12.0.635. Now, when he resizes the figures, they always change correctly. When I run the same code, I can sometimes get a smaller figure than the minimum width and height limits given above. My colleague says this is a Windows 7 interrupt problem. If anyone else has this problem, we found a simple but illogical workaround, which I will post below.

 function cbFigResize(src,evt,doStop) if nargin < 3 doStop = false; end % check if figure width is less than 600 if fpos(3) < 600 %set min. width to 600 fpos(3) = 600 end %check if figure height is less than 560 if fpos(4) <560 % set minimum height to 560 fpos(4) = 560; end if ~doStop cbFigResize(src,evt,true) end 

You can see that this function calls itself with a flag that stops if from an infinite loop. And now I can not resize windows below the minimum. Does anyone know about this behavior?

+4
source share
1 answer

A user at mathworks.com answered this question. His solution solved the problem. I will put the link below. http://www.mathworks.com/matlabcentral/answers/21294-matlab-resizefcn-callback-fails

+1
source

Source: https://habr.com/ru/post/1381340/


All Articles