XNA Window Resize Invokes LoadContent
Anytime I resize my XNA Window to the smallest possible resolution (0 pixels high) the program starts invoking LoadContent again which causes my app to crash (since I only want it to load content once). What can I do, is 开发者_开发百科there a way I can stop the user from resizing my window too much (such as setMinimumSize in Java). Or is there another solution?
Thanks,
To stop the user resizing your window too much, set the MinimumSize property on the form associated with the game window.
Add the following references to your project:
System.Drawing
System.Windows.Forms
Add constants for your desired minimum size:
const int MIN_SIZE_X = 300;
const int MIN_SIZE_Y = MIN_SIZE_X;
Add the following to your constructor or Initialize function.
System.Windows.Forms.Form.FromHandle(Window.Handle).MinimumSize = new System.Drawing.Size(MIN_SIZE_X, MIN_SIZE_Y);
精彩评论