0
votes

I have a C# WPF application, I want it, when launched, to change the screen resolution if it is not what it should work on, like the games.

I know how to retrieve the screen resolution, but I don`t know how to set it to what I want.

NOTE: I`m not working with ASP or WEB, just a desktop APP

2
Just a friendly advice: Remember that most users use LCD screens, which works best at their native resolution. I would deem a desktop program that changes my resolution extremly annoying, and toss it out immediately. - driis
@driis: The app that I`m working on best displayed on a specific resolution, so I was thinking of changing the resolution to what I need, then change it back when focusLost() or app close. - sikas
Yes, driis is right. LCD monitors doesnt work in some resolution, so your application will be unusable to them which doesnt support your resolution. Also if your application crashes, this will make the user to make the resolution to original, which is annoying as well. So I think it is not good idea to do this. - abhishek
Do not be invasive...modify your design to be intuitive enough for user to change settings. Do not mess around with native settings. - Shankar R10N

2 Answers

2
votes

This API function lets you change display settings:

        [DllImport("user32.dll")]
        static extern int ChangeDisplaySettings(
        ref DEVMODE devMode, int flags);

This article explains how to use this function

1
votes

Why do you require this.

I think you should not do this, rather you can build the application within a ViewBox and which let you create Resolution Independent UI.

Please check my article : http://www.dotnetfunda.com/articles/article827-resolution-independent-ui-.aspx