Search Tools Links Login

VB6 Tutorial 64: The Screen Object

Posted: 2018-06-06
By: vb6boy
Viewed: 1,507

Filed Under:

Visual Basic 6

No attachments for this post

One of the objects you can work with in VB6 is the Screen object. This will allow you to find information about the current screen configuration, which will in turn allow you to position your forms and other output in the correct position on the users screen, regardless of the current resolution or dpi settings.


You have come across many controls throughout this tutorial. All the controls i.e CommandButton, Label, TextBox are objects. Besides the form is also an object.

A Collection is an object. If you need a refresher on collections, check out the lesson about collections

Some more examples are Clipboard, Dictionary object, Drive and folder objects, App object, and printer object. There are many. The Screen object is also an object like them.

What is Screen Object?

The one line answer: The screen object corresponds to the visible desktop.

While working with the form's properties, you have set Left, Top, Height and Width properties with a numeric value. Do you know the unit in which they are expressed? They are in twips.

On the printer, 1 inch = 1,440 twips.

Converting twips values into pixels

You can easily convert twips values into pixels using the TwipsPerPixelX and TwipsPerPixelY properties of the screen object.

Your computer screen's resolution:

sWidth = Screen.Width / Screen.TwipsPerPixelX
sHeight = Screen.Height / Screen.TwipsPerPixelY
MsgBox "Resolution is " & sWidth & " X " & sHeight

This will get you the result in pixels.

Properties to know

Have a look at some more properties of the Screen Object.


The MouseIcon property sets a custom mouse icon.

The MousePointer property

Changes the mouse pointer. But it applies to the current application only.

Screen.MousePointer = vbCross

FontCount and Font properties

The FontCount property gives you the number of fonts for the current display device, and the Fonts property returns the font names.

The following program shows the font names.

Dim i As Integer
For i = 0 To Screen.FontCount - 1
    Print Screen.Fonts(i)
Next i

The ActiveForm property

This property returns the form that is the active window.

The ActiveControl property

Returns the control that has the focus.

Screen.ActiveForm.Caption = "New Form"
Screen.ActiveControl.Text = "New text"

The ActiveForm and ActiveControl properties also only applies to the current application.


All the properties except MouseIcon and MousePointer are read-only properties here.

Comments on this post

AnonymousCoward posted this comment on 2020-12-01:

Hi, I'm gho, author of DxWnd tool

I'm looking for a way to hack the Height and Width values returned by the Screen object to let a VB6 fullscreen game run in a window.

Is there a way to make it, like searching for some pattern in memory and overwrite some binary values?

You must be logged in to make a comment.