Solved

screen resolution

Posted on 1998-06-25
3
242 Views
Last Modified: 2010-05-03
let's see if i can explain myself

i want to create an application that doesn't have to bother about the resolution of the screen. For that i think that i have to change the resolution of the screen to my needs and then restore the original resolution when the program ends. is this possible? I mean, can my program change the screen resolution of another computer? how?
Thank you
0
Comment
Question by:turin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
yowkee earned 200 total points
ID: 1464314
turin,

Here's a function to change screen resolution

-------
Private Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean

Private Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwflags As Long) As Long
       Const CCDEVICENAME = 32
       Const CCFORMNAME = 32
       Const DM_PELSWIDTH = &H80000
       Const DM_PELSHEIGHT = &H100000

Private Type DEVMODE
       dmDeviceName As String * CCDEVICENAME
       dmSpecVersion As Integer
       dmDriverVersion As Integer
       dmSize As Integer
       dmDriverExtra As Integer
       dmFields As Long
       dmOrientation As Integer
       dmPaperSize As Integer
       dmPaperLength As Integer
       dmPaperWidth As Integer
       dmScale As Integer
       dmCopies As Integer
       dmDefaultSource As Integer
       dmPrintQuality As Integer
       dmColor As Integer
       dmDuplex As Integer
       dmYResolution As Integer
       dmTTOption As Integer
       dmCollate As Integer
       dmFormName As String * CCFORMNAME
       dmUnusedPadding As Integer
       dmBitsPerPel As Integer
       dmPelsWidth As Long
       dmPelsHeight As Long
       dmDisplayFlags As Long
       dmDisplayFrequency As Long
End Type

Sub ChangeRes(iWidth As Single, iHeight As Single)

    Dim a As Boolean
    Dim i&
    Dim DevM As DEVMODE
   
    i = 0
    Do
        a = EnumDisplaySettings(0&, i&, DevM)
        i = i + 1
    Loop Until (a = False)

    Dim b&
    DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
    DevM.dmPelsWidth = iWidth
    DevM.dmPelsHeight = iHeight
    b = ChangeDisplaySettings(DevM, 0)
End Sub

Private Sub Command1_Click()
    ChangeRes 800, 600
End Sub
--------

However, changing resolution when your app start and end may not be good to user of application.

Regards.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1464315
Although yowkee's answer is more than likely correct (I haven't tested it), I feel you should know that it is bad programming practice to modify the user's screen resolution to suit your application.  Proper programming etiquette would have you changing your interface to suit the user's resolution.

In short, messing with a user's settings won't make him/her very happy.
0
 

Author Comment

by:turin
ID: 1464316
Thanks, the program works great. But i think that you both are right. It's not a good idea to change the resolution. The point was that i wanted to make my program more graphical than it is now and if i have to make different backgrounds for each resolution the program will use too much space.
Nevermind, i will use this only for my personal programs.
Thank you.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question