This is not possible currently. There is an old change request (CCR 317732) with a small number of duplicates - the most recent being over 10 years ago - essentially asking for the viewport to be preserved. There was lots of discussion about it because there's clearly no single right answer (even preserving the viewport involves re-zooming into the previous area, which could be a) expensive for layout, and b) could end up not preserving the area properly depending on how you resized the window). There's no SKILL trigger for a window resize at the moment, otherwise it could have captured the current box before the resize:
and then after resize:
but nothing to do that in one step.
procedure(setWindowMax() let((myScreenCoords myScreenWidth myScreenHeight myScreenHeight window_id) myScreenCoords = getMaxScreenCoords() myScreenWidth = car(myScreenCoords) myScreenHeight = cadr(myScreenCoords) window_id = hiGetCurrentWindow() hiResizeWindow(window_id list(0:0 myScreenWidth:myScreenHeight)) hiZoomAbsoluteScale(window_id 0.9) );end let );end proicedure
In this code，
I don't see this problem (I reformatted your code because it was unreadable and wouldn't work because of the embedded comments, but I didn't make any change).
In IC6.1.8 ISR 33 (IC6.1.8-64b.500.33) then assigning setWindowMax() to a bindkey and pressing that bindkey maximises the window and fits the contents in one go. You didn't say which version you're using - perhaps you can state that. One possibility might be to add hiFlush() after the hiResizeWindow()?