Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8482779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:54:12+00:00 2026-06-10T19:54:12+00:00

basically what I want to do is center a 800×600 game inside a maximized

  • 0

basically what I want to do is center a 800×600 game inside a maximized window. so if the resolution is 1280×1024, there will be a large border, but if the resolution is 800×600 it will take up the whole screen

this is in the Initialize method, it makes the game window fullscreen with a fixed 3d border but the client area also resizes to full screen

Form gameWindowForm = (Form)sys.Form.FromHandle(this.Window.Handle);
gameWindowForm.FormBorderStyle = FormBorderStyle.Fixed3D;
gameWindowForm.Text = "";
gameWindowForm.ControlBox = false;
gameWindowForm.WindowState = sys.FormWindowState.Maximized;

I have tried setting preferred back buffer, clientbounds size, viewport and displaymode. No matter what I try to resize I either can’t because it is read only or it doesn’t change anything.

Any help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:54:14+00:00Added an answer on June 10, 2026 at 7:54 pm

    If you want to customise the window layout, perhaps try the official WinForms sample. There’s no “official” way in XNA to mess with the client area within the window.

    However if all you want to do is center the rendering region within the window, then you should be able to do that just by setting the viewport at the beginning of each frame, like so:

    int width = GraphicsDevice.PresentationParameters.BackBufferWidth;
    int height = GraphicsDevice.PresentationParameters.BackBufferHeight;
    GraphicsDevice.Viewport = new Viewport(
            width/2 - 800/2, height/2 - 600/2, 800, 600);
    

    (Note that this code will fail if your window gets too small and the viewport exceeds the screen size – so you’ll want to check for that and respond – maybe by using a smaller viewport.)

    Just keep in mind that GraphicsDevice.Clear will clear the entire backbuffer in XNA 4.0, not just the viewport (so instead just draw a flat-coloured rectangle across the viewport).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I basically want to setup a relationship similar to Netflix's DVD rental model. There
I basically want to open a browser window from Word using VBA that does
Basically, I want to center text, ignoring any floating sibling elements. At first, I
Basically I want to know how to set center alignment for a cell using
Basically I want to put the div tags below in the center of the
I basically want something like: TextView Button Button . . . TextView TextView SeekBar
I basically want to do: git checkout branchA git checkout -b branchB <commit_id> which
I basically want the same functionality as facebook, twitter and all those other infinite
I basically want to do this in code: PersonList myPersonList; //populate myPersonList here, not
I basically want to be able to deploy multiple versions of the same EAR

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.