Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Changing Screen Resolution through C#

Changing Screen Resolution through C#

Scheduled Pinned Locked Moved C#
questioncsharp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thepolishguy
    wrote on last edited by
    #1

    I want to provide operators of my C# software the opportunity to change screen resolution to optimal settings (1024x768) for viewing this particular software. How do I change screen resolution (and maintain those changed settings), should the user opt to do so? -- modified at 11:08 Tuesday 20th December, 2005 I should have added the following. The computer that will be running the program is, in this case, a dedicated machine. It's purpose is basically to run the software I'm developing. As such, it makes a certain sense to have the display settings optimal for the particular application-should the operator opt to set them that way. The operator is under no obligation to set the computer to those optimal settings and will have the option to not see the message box again after the initial run of the program.

    A D 2 Replies Last reply
    0
    • T thepolishguy

      I want to provide operators of my C# software the opportunity to change screen resolution to optimal settings (1024x768) for viewing this particular software. How do I change screen resolution (and maintain those changed settings), should the user opt to do so? -- modified at 11:08 Tuesday 20th December, 2005 I should have added the following. The computer that will be running the program is, in this case, a dedicated machine. It's purpose is basically to run the software I'm developing. As such, it makes a certain sense to have the display settings optimal for the particular application-should the operator opt to set them that way. The operator is under no obligation to set the computer to those optimal settings and will have the option to not see the message box again after the initial run of the program.

      A Offline
      A Offline
      Andy Moore
      wrote on last edited by
      #2

      You can do this by using P/Invoke to access the Win32 API from your C# code. Have a look at the ChangeDisplaySettings function and the DEVMODE structure. You will need to create the DEVMODE structure in your code and use DllImport to call ChangeDisplaySettings. The following link documents the DEVMODE structure. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/prntspol_8nle.asp[^] I hope this helps. Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons

      1 Reply Last reply
      0
      • T thepolishguy

        I want to provide operators of my C# software the opportunity to change screen resolution to optimal settings (1024x768) for viewing this particular software. How do I change screen resolution (and maintain those changed settings), should the user opt to do so? -- modified at 11:08 Tuesday 20th December, 2005 I should have added the following. The computer that will be running the program is, in this case, a dedicated machine. It's purpose is basically to run the software I'm developing. As such, it makes a certain sense to have the display settings optimal for the particular application-should the operator opt to set them that way. The operator is under no obligation to set the computer to those optimal settings and will have the option to not see the message box again after the initial run of the program.

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        What you're doing is not recommended, and, in fact, actively discouraged. Changing system-wide settings affects other applications that are running and also affects the layout of the desktop. Remember, Windows is a shared system, running multiple applications at once. You have to make sure you app works and plays nice with others. Changing system-wide settings so your app looks good, can make another app running at the same time look bad. I know if you did that to my machine while I'm working in Maya at 1900x1440, I'd be heading straight for Add/Remove Programs and dumping your app. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        D 1 Reply Last reply
        0
        • D Dave Kreskowiak

          What you're doing is not recommended, and, in fact, actively discouraged. Changing system-wide settings affects other applications that are running and also affects the layout of the desktop. Remember, Windows is a shared system, running multiple applications at once. You have to make sure you app works and plays nice with others. Changing system-wide settings so your app looks good, can make another app running at the same time look bad. I know if you did that to my machine while I'm working in Maya at 1900x1440, I'd be heading straight for Add/Remove Programs and dumping your app. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          D Offline
          D Offline
          Dan Neely
          wrote on last edited by
          #4

          Dave Kreskowiak wrote:

          I know if you did that to my machine while I'm working in Maya at 1900x1440, I'd be heading straight for Add/Remove Programs and dumping your app.

          In general, agreed. THe only time forcing a resolution should be allowed is in full screen mode, and then be sure to restore the settings when the user closes or alt-tabs out of your program.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups