Limiting application window size

Hey everyone,

I was hoping to grab some help with my problem. I want to limit my application window so it doesn’t go under a certain resolution (example no smaller than 400x200).

I currently have logic that checks the current window size, and if its outside of a certain ratio, resize to target ratio. I can redo this logic but the problem with it is the window flickers between resolutions and its a little gross.

I want to mimic something similar to Unity editor. There is a limit to when you try and resize the window so it doesn’t go below a certain resolution.

Has anyone done something like this before and able to point me in the right direction? Sample code would also be welcomed.

Thanks!

I assume you are targeting Windows Standalone? If so, it’s going to be a bit tricky. Unity hard codes the minimum window size to 128x128 right now.

To do this, you need to subclass Unity’s WndProc and override WM_GETMINMAXINFO window message: About Window Procedures - Win32 apps | Microsoft Learn

Yes correct, we are doing windows standalone.

Ok we will have a look into it thanks! Is there a reason why the field is not exposed through Unity’s API?

Not really, it’s just not something we thought that games would need. Also, it doesn’t really map well to different platforms.

Thanks for that :slight_smile:

Hi all, just for a 2022 update on this issue (and filling in some gaps from the thread below):

  • Is it possible to set the minimum size for a non-UWP app? I.e. just a standard Windows .exe using Mono?
  • I assume the best way to do this on Mac would be to generate an. Xcode project and add the native API calls there. Is that correct?