473,320 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to change screen resolution in c#?

10
I have a program-a Game, and I want that it will fit all the screens. so I want to change the resolution of the screen in my code,
I tried to use a program which I have found in google but it didn't work.
what can I do?
Is there anyone who can help me?
thanks.
Feb 24 '11 #1

✓ answered by st mnmn

I found an answer!!!!!!!
I used this
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=setscreenresolution&lang=en>

though it's in VB, I created a new VB project with class library. and pasted the code from the URL above in that class.
I added references to my c# project to this class library-dll and used it successfully!!!!
good luck

6 5354
st mnmn
10
I found an answer!!!!!!!
I used this
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=setscreenresolution&lang=en>

though it's in VB, I created a new VB project with class library. and pasted the code from the URL above in that class.
I added references to my c# project to this class library-dll and used it successfully!!!!
good luck
Feb 24 '11 #2
GaryTexmo
1,501 Expert 1GB
I'm glad you found a solution; however, I'd like to make a few comments.

Unless your game is full screen, I'd advise against changing the resolution on your users. This is going to change their desktop resolution which could change the way other applications behave, and at a minimum, could muck up their nice icon placement! :)

Instead, I'd suggest doing one of two things...

1) Update your game to support multiple resolutions. You quite easily detect the screen resolution in C# and if it's beyond a certain threshold, scale up your images and game area.

2) Use a game development platform, either DirectX or XNA. Personally, I'd recommend giving XNA a try actually, it's pretty easy to use and works quite well. You can then make your game full screen and it will use the resolution you tell it. XNA supports this automatically.
Feb 24 '11 #3
st mnmn
10
Thanks for your comments, you're right!
I think I should use your first suggestion:
Update my game to support multiple resolutions.
Can you give me more details how to do that?
Thanks a lot!!!
Feb 27 '11 #4
GaryTexmo
1,501 Expert 1GB
I'd still highly recommend checking out something like XNA as this is definitely the easier approach, but I can certainly help you work through the scaling approach :)

I'm actually going to write an insight on this. Check back later and I'll update this thread with a link.
Feb 28 '11 #5
GaryTexmo
1,501 Expert 1GB
Ok, I've finished. Have a read here and if you have any questions, please post back in this thread and let me know.

http://bytes.com/topic/c-sharp/insig...ng-resolutions
Feb 28 '11 #6
st mnmn
10
Thanks a lot!!!!
Your article is very clear!!!
Thanks for your helping!
Mar 1 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Dave | last post by:
About a week ago, I upped my screen resolution from 800x600 to 1024x768. From that point on, I started making gradual adjustments to my web site, in which the margins are tailored to 800 pixels...
0
by: Soobrassen Thoplan | last post by:
Hi to all I'm a vb dot net programmer and would like to know how i can chage the resolution of an screen dynamically and reset it when the user exit my software. Actually i can do it with vb 6.0...
4
by: pjac | last post by:
I need some help with some VB language that will change the screen resolution on a monitor when a MS-Access 2000 database is opened from 1024 x 768 to 800 x 600. Any help with this effort would be...
8
by: lauren quantrell | last post by:
Is there a way to force a change in a user's screen resolution using VBA code without having any input from the user? Example: User John Backwards has his screen set to 800 x 600 pixels. Backwards...
0
by: JaimeM26 | last post by:
I have been able to determine the resolution on the users machine, but i am looking for a way to force the resolution to 1024 X 768 if it is not that already. Can someone please help me with this....
7
by: JaimeM26 | last post by:
I have been able to determine the resolution on the users machine, but i am looking for a way to force the resolution to 1024 X 768 if it is not that already in VB.NET. Can someone please help me...
9
by: murathan | last post by:
How to Change Screen Resolution ?
1
by: Tea Maker | last post by:
Hi, I have an application that is best viewed at 1024x768. I know that changing the screen resolution might cause some problems, but it's very important that I go on with this. So my plan is,...
0
by: sheshusankhya | last post by:
how to change screen resolution in flash is it possible? how?
3
by: angelicdevil | last post by:
say the screen solution is 800 *600 how can i get the browser to change the resolution so that my site appears in the resolution it was made but on closing the or changing the browser tab it changes...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.