I'm overriding the WM_SIZE message so that I can lock my form into a specific aspect ratio. I'm allowing the user to turn on and off aspect ratio locking by toggling a checkbox. So far resizing by the edges (left, right, top, bottom) works just fine, but I'm running into a problem when I get to the corners.
I'm using Camtasia's screen recorder as my reference. In that program, when you lock the aspect ratio and resize by the corners it allows to resize both width and height, while maintaining the aspect ratio of the bounds. With my math, it's one or the other: width or height. I can't figure out how to make it do both.
I'm testing on the top-right corner to start with. I've got a RECT structure with my form rectangle, here's the math I can use to size either the left or top:
r.Left = r.Right - (int)(sizeRatio .Width * this.Height / sizeRatio.Heigh t);
r.Top = r.Bottom - (int)(sizeRatio .Height * this.Width / sizeRatio.Width );
But that only works if I've only got one active, if I use both at the same time it doesn't resize at all.
Basically I want it so that if the user is resizing by the top left and they drag their mouse out to the left, the left edge will stay with the mouse and the top will move up; if they move their mouse up, the top will stay with the mouse and the left will move resize out. Does that make sense? Basically, with the corners, changing the width changes the height and changing the height changes the width. How can I do that?
I'm using Camtasia's screen recorder as my reference. In that program, when you lock the aspect ratio and resize by the corners it allows to resize both width and height, while maintaining the aspect ratio of the bounds. With my math, it's one or the other: width or height. I can't figure out how to make it do both.
I'm testing on the top-right corner to start with. I've got a RECT structure with my form rectangle, here's the math I can use to size either the left or top:
r.Left = r.Right - (int)(sizeRatio .Width * this.Height / sizeRatio.Heigh t);
r.Top = r.Bottom - (int)(sizeRatio .Height * this.Width / sizeRatio.Width );
But that only works if I've only got one active, if I use both at the same time it doesn't resize at all.
Basically I want it so that if the user is resizing by the top left and they drag their mouse out to the left, the left edge will stay with the mouse and the top will move up; if they move their mouse up, the top will stay with the mouse and the left will move resize out. Does that make sense? Basically, with the corners, changing the width changes the height and changing the height changes the width. How can I do that?
Comment