-2

I want to limit the resize range of a windows width based on the height. I do this via WM_GETMINMAXINFO, but there is a quirk (at least in Win10). If at the time of starting the resize and my window height supports a minimum width of say 80, it never goes below 80. As I am dragging if I reduce the height so that it changes the minimum width to be 100, it honors that, but if I dragged and increased the height so the minimum width changes to 60, it still stops at 80 (the WM_GETMINMAXINFO is being called all along the way). Is there a trick to get it to work?

One trick I thought of is if I could detect the start of the resize, i could just use some minimum of something like 10, but then the next requests would use the actual real values and would solve the issue. Any thoughts?

TIA!!

df234987
  • 513
  • 2
  • 13
  • 2
    You have no control over when `WM_GETMINMAXINFO` is sent; it's up to the OS when it wants to send a query and whether it caches the results or not. If you want to lock sizing of your window to certain aspect ratios (which is what it sounds like) then I suggest you handle `WM_WINDOWPOSCHANGING`; this lets you make changes to your window size while it is being resized. – Jonathan Potter Mar 09 '20 at 12:03
  • Moved the logic from WM_GETMINMAXINFO over to WM_WINDOWPOSCHANGING and now works as expected. – df234987 Mar 09 '20 at 22:39

1 Answers1

0

Add the logic to WM_WINDOWPOSCHANGING instead of using WM_GETMINMAXINFO.

case WM_WINDOWPOSCHANGING:
{
  // call default handler
  ::DefWindowProc(hwnd, umsg, wparam, lparam);

  // get structure pointer
  WINDOWPOS *wp=(WINDOWPOS *) lparam;

  // ... add logic here ...

  return 0;
}
df234987
  • 513
  • 2
  • 13