Solved

screen resolution

Posted on 1998-06-25
3
239 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
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB 6.0 printer how to align 6 62
Prevent user closing word document opened with VB6 6 74
TT Auto Dashboard 13 92
Macro Excel - Multiple If conditions 2 72
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

773 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