Solved

screen resolution

Posted on 1998-06-25
3
234 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now