The Screen class exposes many properties, all useful in particular circumstances, but all very specific. If you’re not using a Japanese version of Windows, for example, you’ll never have a need for the KanjiWindow property. On the other hand, you may often need the ScreenX and ScreenY properties. We can’t begin to suggest reasons you’d need all these properties; we’ve simply provided them here, as properties of a Screen object, because Windows makes them available. Experiment with the read/write properties to see their effect on your environment before unleashing them in your applications.
As with other objects, working with these properties requires only creating an instance of the Screen object:
Dim oScreen As New Screen
oScreen.MinAnimation = False
oScreen.IconFontName = "Tahoma"
If oScreen.ScreenX > 1024 Then
MsgBox "You have a very large amount of screen real estate!"
End If
Working with the methods of the Screen object requires a bit more information. The GetWorkArea and SetWorkArea methods allow you to control the area that Windows thinks is available for maximized windows. You can retrieve the coordinates of this region, and you can modify them as well.
To retrieve the coordinates of the work area, you must pass four long integer variables to the GetWorkArea method. It fills in the value of the four long integers for you. To set the new work area, call SetWorkArea, passing one or more of the four coordinates. If you omit a coordinate when you call SetWorkArea, the code will use the current setting for that coordinate. This way, you can modify one or more of the coordinates without having to pass them all in. Once you’ve called the following code fragment, maximizing a window will leave empty space at the bottom because you’ve changed what Windows thinks is its work area for maximized windows:
Dim lngLeft As Long
Dim lngTop As Long
Dim lngRight As Long
Dim lngBottom As Long
Dim oScreen As New Screen
' Get the current work area:
Call oScreen.GetWorkArea(lngLeft, lngTop, lngRight, lngBottom)
' Move the bottom up by 10%:
lngBottom = Int(.90 * lngBottom)
Call oScreen.SetWorkArea(Bottom:=lngBottom)