How to maximize window in XNA

后端 未结 5 2033
离开以前
离开以前 2021-01-14 22:35

This SHOULD be a very simple question but after lots of searching there seems to be no working example anywhere. I just want my XNA window to start off maximized. I know how

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-14 23:17

    Others have covered the step of maximizing automatically, but to enable the actual maximize button so the user can do it when desired, do this in the Game constructor:

    Window.AllowUserResizing = true; 
    

    Depending on how you want the game to behave when resizing begins and ends, perhaps pause the game, you may need to handle some of these events.

        Form form = (Form)Form.FromHandle(Window.Handle);
        form.ResizeBegin += new EventHandler(form_ResizeBegin);
        form.ResizeEnd += new EventHandler(form_ResizeEnd);
        form.LocationChanged += new EventHandler(form_LocationChanged);
    

提交回复
热议问题