Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Screen Resolution Determination 1

Status
Not open for further replies.

tenbobmillionaire

Programmer
Jun 13, 2000
27
EU
Is there a function available that lets VB determine the screen resolution of the pc on which the program is running?
Thanks
Mick
 
Robosize v1.2 Date: December 13, 1998

Robosize freeware control, adapts the size of forms and controls so they will appear the same for all screen resolution. VB 5/6

Download: Site 1 Homepage: Robocx
File Size: 180 Kb



Never tried it, not that far along in VB yet. In my "travels" i remembered seeing it so I went back and found it for ya. Hope it's what your looking for. ;-)
 
You can find out this way:
[tt]
Private Declare Function GetSystemMetrics Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
Private Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1

Dim lWidth as Long
Dim lHeight as Long

lWidth = GetSystemMetrics(SM_CXSCREEN)
lHeight = GetSystemMetrics(SM_CYSCREEN)
[/tt]

Note that this returns the resolution of the primary monitor only. If you have a multiple-monitor system and want to determine the size of specific secondary monitors, you'll have to use the GetDeviceCaps call with a handle to the monitor in question. If you want the size of the virtual screen presented by multiple monitors, then you can again use the GetSystemMetics call, but with SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN parameters.

Hope this helps.
Chip H.
 
take a VB systeminfo control from components :

This example tests the size of the active form after a change in screen resolution and adjusts the size of the form if it exceeds the visible screen area. To run this example, put a SysInfo control on a form. Paste this code into the DisplayChanged event of the SysInfo control. Run the example, then change the screen resolution.

Private Sub SysInfo1_DisplayChanged()
If Screen.ActiveForm.Width > SysInfo1.WorkAreaWidth Then
Screen.ActiveForm.Left = SysInfo1.WorkAreaLeft
Screen.ActiveForm.Width = SysInfo1.WorkAreaWidth
End If
If Screen.ActiveForm.Height > SysInfo1.WorkAreaHeight Then
Screen.ActiveForm.Top = SysInfo1.WorkAreaTop
Screen.ActiveForm.Height = SysInfo1.WorkAreaHeight
End If
End Sub

Eric De Decker
vbg.be@vbgroup.nl

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top