Search code examples
c#performancefullscreenscreen-resolution

Fullscreen Form with a maximum form size lagging


I'm making a game, and all of the pictureboxes sizes and locations are based on an 1920x1080 resolution (as that is my screen size). But when the game is played on a different resolution, the game doesn't fullscreen, (using FormBorderStyle = FormBorderStyle.None; and WindowState = FormWindowState.Maximized;), because I have set the maximum form size as 1920x1080. The problem is, that when the game is played on a bigger resolution monitor and the form doesn't fill up the entire screen, the game gets extremely laggy and slow. Is there any way to fix this? Perhaps by adding black bars around the game?


Solution

  • Assuming your game depends on the Screen and the Window being that exact size to work properly, you could move the entire game into a UI Panel, and center that in the window. This would probably require a lot of reworking of your code.

    Or you could go the lazy way of opening open a new Window instead of the game from your Program.cs that is entirely black and maximize that, and then open the Game-Window Center-Screen at 1920x1080 without maximizing it as a Dialog from the background window, so it is always in front of the black one.