473,320 Members | 1,979 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.

Changing Screen Resolution

I am wondering how (if it is possible of course) I can change a users
screen resolution to a certain size when running my application and
then change it back when they exit my application.

For instance, if the users screen size is 800x600, I want the
resolution to change to 1260x780 when running my program and then
change back to 800x600 when exiting my program.

Thanks,
Darian
Nov 21 '05 #1
6 2651
http://abstractvb.com/code.asp?A=947

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Darian" <da***********@lmicorporation.com> wrote in message
news:fa*************************@posting.google.co m...
I am wondering how (if it is possible of course) I can change a users
screen resolution to a certain size when running my application and
then change it back when they exit my application.

For instance, if the users screen size is 800x600, I want the
resolution to change to 1260x780 when running my program and then
change back to 800x600 when exiting my program.

Thanks,
Darian

Nov 21 '05 #2
Here's another link.

http://www.omniscium.com/index.asp?p...reenResolution

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:OS****************@TK2MSFTNGP14.phx.gbl...
http://abstractvb.com/code.asp?A=947

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Darian" <da***********@lmicorporation.com> wrote in message
news:fa*************************@posting.google.co m...
I am wondering how (if it is possible of course) I can change a users
screen resolution to a certain size when running my application and
then change it back when they exit my application.

For instance, if the users screen size is 800x600, I want the
resolution to change to 1260x780 when running my program and then
change back to 800x600 when exiting my program.

Thanks,
Darian


Nov 21 '05 #3
* da***********@lmicorporation.com (Darian) scripsit:
I am wondering how (if it is possible of course) I can change a users
screen resolution to a certain size when running my application and
then change it back when they exit my application.

For instance, if the users screen size is 800x600, I want the
resolution to change to 1260x780 when running my program and then
change back to 800x600 when exiting my program.


There is no managed way to do that.

From my FAQ (<URL:http://dotnet.mvps.org/faqs/>):

This solution is based on a sample written by Tom Spink.

Changing the screen resolution makes sense in very few cases, but it is
possible using p/invoke. 'SetResolution' tries to change the screen
resolution to the values passed into the method and returns 'False' if
changing the screen settings fails:

\\\
Imports System.Runtime.InteropServices
..
..
..
Private Declare Auto Function EnumDisplaySettings Lib "user32.dll" ( _
<MarshalAs(UnmanagedType.LPTStr)> ByVal lpszDeviceName As String, _
ByVal iModeNum As Int32, _
ByRef lpDevMode As DEVMODE _
) As Boolean

Private Declare Auto Function ChangeDisplaySettings Lib "user32.dll" ( _
ByRef lpDevMode As DEVMODE, _
ByVal dwFlags As Int32 _
) As Int32

Private Const DM_BITSPERPEL As Int32 = &H40000
Private Const DM_PELSWIDTH As Int32 = &H80000
Private Const DM_PELSHEIGHT As Int32 = &H100000

Private Const DISP_CHANGE_SUCCESSFUL As Int32 = 0

<StructLayout(LayoutKind.Sequential)> _
Private Structure POINTL
Public x As Int32
Public y As Int32
End Structure

<StructLayout(LayoutKind.Explicit)> _
Private Structure DEVMODE_union1
' struct {
<FieldOffset(0)> Public dmOrientation As Int16
<FieldOffset(2)> Public dmPaperSize As Int16
<FieldOffset(4)> Public dmPaperLength As Int16
<FieldOffset(6)> Public dmPaperWidth As Int16
' }
<FieldOffset(0)> Public dmPosition As POINTL
End Structure

<StructLayout(LayoutKind.Explicit)> _
Private Structure DEVMODE_union2
<FieldOffset(0)> Public dmDisplayFlags As Int32
<FieldOffset(0)> Public dmNup As Int32
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _
Private Structure DEVMODE
Private Const CCDEVICENAME As Int32 = 32
Private Const CCFORMNAME As Int32 = 32

<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=CCDEVICENAME)> _
Public dmDeviceName As String
Public dmSpecVersion As Int16
Public dmDriverVersion As Int16
Public dmSize As Int16
Public dmDriverExtra As Int16
Public dmFields As Int32
Public u1 As DEVMODE_union1
Public dmScale As Int16
Public dmCopies As Int16
Public dmDefaultSource As Int16
Public dmPrintQuality As Int16
Public dmColor As Int16
Public dmDuplex As Int16
Public dmYResolution As Int16
Public dmTTOption As Int16
Public dmCollate As Int16
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=CCFORMNAME)> _
Public dmFormName As String
Public dmUnusedPadding As Int16
Public dmBitsPerPel As Int16
Public dmPelsWidth As Int32
Public dmPelsHeight As Int32
Public u2 As DEVMODE_union2
Public dmDisplayFrequency As Int32
Public dmICMMethod As Int32
Public dmICMIntent As Int32
Public dmMediaType As Int32
Public dmDitherType As Int32
Public dmReserved1 As Int32
Public dmReserved2 As Int32
Public dmPanningWidth As Int32
Public dmPanningHeight As Int32
End Structure

Public Function SetResolution( _
ByVal Width As Int32, _
ByVal Height As Int32, _
ByVal BitsPerPixel As Int16 _
) As Boolean
Dim dm As DEVMODE
If Not EnumDisplaySettings(Nothing, 0, dm) Then
Return False
Else
With dm
.dmFields = _
DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL
.dmPelsWidth = Width
.dmPelsHeight = Height
.dmBitsPerPel = BitsPerPixel
End With
Return (ChangeDisplaySettings(dm, 0) = DISP_CHANGE_SUCCESSFUL)
End If
End Function
///

Usage:

\\\
Debug.Assert(SetResolution(1024, 768, 32))
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4
If you're sure you want your app to do this, remember you'll have to address
the situation of what to do when the user minimizes the screen.

Just my 2 cents.

"Darian" <da***********@lmicorporation.com> wrote in message
news:fa*************************@posting.google.co m...
I am wondering how (if it is possible of course) I can change a users
screen resolution to a certain size when running my application and
then change it back when they exit my application.

For instance, if the users screen size is 800x600, I want the
resolution to change to 1260x780 when running my program and then
change back to 800x600 when exiting my program.

Thanks,
Darian

Nov 21 '05 #5
Thanks Randall, you just opened my eyes to a couple of unknowns. I
think that I will scrap the idea of changing screen resolutions. I
just wanted to try to figure out a way to have my application run if
someone is stupid and changes their resolution to something small like
800x600.

Thanks again everybody.
Darian
Nov 21 '05 #6
On 8 Sep 2004 07:18:29 -0700, da***********@lmicorporation.com (Darian) wrote:

¤ I am wondering how (if it is possible of course) I can change a users
¤ screen resolution to a certain size when running my application and
¤ then change it back when they exit my application.
¤
¤ For instance, if the users screen size is 800x600, I want the
¤ resolution to change to 1260x780 when running my program and then
¤ change back to 800x600 when exiting my program.

This is a no-no. First there is no guarantee that the user's setup will support the higher
resolution, and second, I don't know many users that would appreciate having their screen resolution
changed on the fly without being offered the option to do so. Any application which did this would
be uninstalled from my machine in a heartbeat.

I would simply check their current screen resolution and display a message which indicates that your
application requires a higher resolution to function properly. Allow them to decide whether to
change the resolution through your application or via the Display Control Panel applet.
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Julius Mong | last post by:
Dear all, I have the following: <html> <head> .... </head> <frameset ...> <frame .../> <frameset name="page" rows="60,*" ...> <frame src='top.html' .../>
5
by: jlombardo | last post by:
I've read previous posts and know it is "bad form" to change a user's screen resolution to fit your program's needs. My situation is very different. I have a user with a laptop resolution of...
2
by: VMI | last post by:
How can I change the size of the forms in my Windows application when the screen resolution the user has is higher than the one I developed the application in? I have a customer that has a screen...
5
by: Maxi | last post by:
I have a 30X16 cells table in my html page. Table height and width are set to 100%. I have set size of every cell inside the table to 24 pixel. When I open the html page in maximize state in...
9
by: Steve Wright | last post by:
Hi I'm developing a webpage that needs to include a different stylesheet depending on the screen resolution. I know that I could read the resolution in javascript and then do some sort of...
0
by: A. User | last post by:
All, I created an Access 2000 MDE application in 1024x768. A user of mine, who is running Vista with Office 2007, can not see the entire application- the right most side is off the screen. No...
4
by: PrakashN | last post by:
I have one project it was developed in 800 X 600 pixel screen resolution. Now I changed screen resolution to 1024 X 768. Forms size is reduced. How can I get full screen? Please help me.
1
by: nasima khan | last post by:
Hi, i am nasima. I have got a code for setting the screen resolution of my page, but i am unable to understand. Can any one give a complete data explanation of the below code. Sub ChangeRes(X...
10
by: =?Utf-8?B?UmljaA==?= | last post by:
A lot of users at my workplace use different screen resolutions, and I build apps to use 1680 x 1050 pixels res by default. But some users are using 800 x 600, and the apps are too large for their...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
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....

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.