LOCAL lnNewHeight, lnNewWidth lnNewHeight = This.Height lnNewWidth = This.Width LOCAL lnOldRatio, lnNewRatio lnOldRatio = This.nOrigHeight/This.nOrigWidth lnNewRatio = m.lnNewHeight/m.lnNewWidth * Lay out cases * Case 1: Same --> we're done * Case 2: lnNewRatio > lnOldRatio * Case 2a: lnNewHeight > This.nLastHeight --> height grew more than width, fix width * Case 2b: lnNewHeight < This.nLastHeight --> width shrunk more than height, fix height * Case 2c: heights are the same --> width shrunk more than height, fix height * Case 3: lnNewRatio < lnOldRatio * Case 3a: lnNewHeight < This.nLastHeight --> height shrunk more than width, fix width * Case 3b: lnNewHeight > This.nLastHeight --> width grew more than height, fix height * Case 3c: heights are the same --> width grew more than height, fix height * * Fix height --> This.nOrigHeight * (m.lnNewWidth/This.nOrigWidth) * Fix width --> This.nOrigWidth * (m.lnNewHeight/This.nOrigHeight) * * Examples: * Assume This.nOrigHeight = 4 and This.nOrigWidth = 2, so lnOldRatio = 2 * Each example assumes starting from original, not previous case * * lnNewHeight | lnNewWidth | lnNewRatio | Case | Result * 5 | 2 | 2.5 | 2a | set width to 2.5 * 5 | 3 | 1.67 | 3b | set height to 6 * 4 | 3 | 1.33 | 3c | set height to 6 * 3 | 2 | 1.5 | 3a | set width to 1.5 * 3 | 1 | 3 | 2b | set height to 2 * 4 | 1 | 4 | 2c | set height to 2 DO CASE CASE m.lnNewRatio = m.lnOldRatio && Case 1 * Nothing to do, just get out CASE m.lnNewRatio > m.lnOldRatio && Case 2 IF m.lnNewHeight > This.nLastHeight * Case 2a This.Width = ROUND(This.nOrigWidth * m.lnNewHeight / This.nOrigHeight, 0) ELSE * Case 2b and 2c This.Height = ROUND(This.nOrigHeight * m.lnNewWidth / This.nOrigWidth, 0) ENDIF CASE m.lnNewRatio < m.lnOldRatio && Case 3 IF m.lnNewHeight < This.nLastHeight * Case 3a This.Width = ROUND(This.nOrigWidth * m.lnNewHeight / This.nOrigHeight, 0) ELSE * Case 3b and 3c This.Height = ROUND(This.nOrigHeight * m.lnNewWidth / This.nOrigWidth, 0) ENDIF ENDCASE This.nLastHeight = This.Height This.nLastWidth = This.Width RETURNIf anyone sees somewhere that I'm off-track, please tell me. Also, if anyone has done this successfully, please tell me how.