Hi All,
I am currently working on a product using vb and ms- access..
I want to change the resolution of my own software irrespective of windows settings
as done in case of various games.The product best works on 800-600
2 1541
Hi
I'm using this for some of my program. This example came from allapi.net -
-
Option Explicit
-
Const WM_DISPLAYCHANGE = &H7E
-
Const HWND_BROADCAST = &HFFFF&
-
Const EWX_LOGOFF = 0
-
Const EWX_SHUTDOWN = 1
-
Const EWX_REBOOT = 2
-
Const EWX_FORCE = 4
-
Const CCDEVICENAME = 32
-
Const CCFORMNAME = 32
-
Const DM_BITSPERPEL = &H40000
-
Const DM_PELSWIDTH = &H80000
-
Const DM_PELSHEIGHT = &H100000
-
Const CDS_UPDATEREGISTRY = &H1
-
Const CDS_TEST = &H4
-
Const DISP_CHANGE_SUCCESSFUL = 0
-
Const DISP_CHANGE_RESTART = 1
-
Const BITSPIXEL = 12
-
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
-
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
-
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
-
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
-
Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As Any) As Long
-
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
-
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
-
Dim OldX As Long, OldY As Long, nDC As Long
-
Sub ChangeRes(X As Long, Y As Long, Bits As Long)
-
Dim DevM As DEVMODE, ScInfo As Long, erg As Long, an As VbMsgBoxResult
-
'Get the info into DevM
-
erg = EnumDisplaySettings(0&, 0&, DevM)
-
'This is what we're going to change
-
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL
-
DevM.dmPelsWidth = X 'ScreenWidth
-
DevM.dmPelsHeight = Y 'ScreenHeight
-
DevM.dmBitsPerPel = Bits '(can be 8, 16, 24, 32 or even 4)
-
'Now change the display and check if possible
-
erg = ChangeDisplaySettings(DevM, CDS_TEST)
-
'Check if succesfull
-
Select Case erg&
-
Case DISP_CHANGE_RESTART
-
an = MsgBox("You've to reboot", vbYesNo + vbSystemModal, "Info")
-
If an = vbYes Then
-
erg& = ExitWindowsEx(EWX_REBOOT, 0&)
-
End If
-
Case DISP_CHANGE_SUCCESSFUL
-
erg = ChangeDisplaySettings(DevM, CDS_UPDATEREGISTRY)
-
ScInfo = Y * 2 ^ 16 + X
-
'Notify all the windows of the screen resolution change
-
SendMessage HWND_BROADCAST, WM_DISPLAYCHANGE, ByVal Bits, ByVal ScInfo
-
MsgBox "Everything's ok", vbOKOnly + vbSystemModal, "It worked!"
-
Case Else
-
MsgBox "Mode not supported", vbOKOnly + vbSystemModal, "Error"
-
End Select
-
End Sub
-
Private Sub Form_Load()
-
Dim nDC As Long
-
'retrieve the screen's resolution
-
OldX = Screen.Width / Screen.TwipsPerPixelX
-
OldY = Screen.Height / Screen.TwipsPerPixelY
-
'Create a device context, compatible with the screen
-
nDC = CreateDC("DISPLAY", vbNullString, vbNullString, ByVal 0&)
-
'Change the screen's resolution
-
ChangeRes 800, 600, GetDeviceCaps(nDC, BITSPIXEL)
-
End Sub
-
Private Sub Form_Unload(Cancel As Integer)
-
'restore the screen resolution
-
ChangeRes OldX, OldY, GetDeviceCaps(nDC, BITSPIXEL)
-
'delete our device context
-
DeleteDC nDC
-
End Sub
-
-
Rey Sean
Hi Rey Sean,
It is also helpful for others.
Regards, shuvo2k6 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Erik Bethke |
last post by:
Hello All,
I am trying to clean up some polish bugs with the Shanghai game I am
working on and I am currently stuck on trying to get the right event
for detecting when the user has changed the...
|
by: Erik Bethke |
last post by:
Hello All,
I am trying to clean up some polish bugs with the Shanghai game I am
working on and I am currently stuck on trying to get the right event
for detecting when the user has changed the...
|
by: Jeroen van vliet |
last post by:
Hello,
my website is best viewed, and specially designed for 1024 X 786 and higher,
when shown on 800 X 600 it look horrible, now is it possible when the viewer
enters my site, his/her...
|
by: techie |
last post by:
Hi All,
I have a portal working on an intranet for a company. The portal was
designed keeping in mind the resolution of 1024*768. I am including a
..css file in all the files. Now i have to make...
|
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...
|
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...
|
by: Bertrand1978 |
last post by:
Hi All.
I am using VC++/Visual Studio 6.0. I can get the current screen resolution
with GetSystemMetrics(), but how do you change the screen resolution ? I
guess I couldn't find a...
|
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...
|
by: Lad |
last post by:
Is it possible to change a picture resolution with Python?
Let's say I have a picture with a resolution of 96 dpi and I would like
to increase to 256dpi or higher.
Thank you for your reply.
LL
|
by: miladhatam |
last post by:
can i change the size of a file dynamically ?
for example have 100 Kb and i want to decrease it to 20 Kb
thanks
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |