F.A.Q. - When I display my form on another PC (which has a different large fonts/small fonts setting to the one it was created on) my background picture appears smaller/larger than it should. How can I stop this happening?

The problem here is that when Windows is set to 'Large Fonts' in the display settings it automatically scales up all the controls on a form, and any normal forms too. For this reason I have included code which will scale the shaped form accordingly. Unfortunately background pictures don't scale automatically, and you must code this effect yourself.

The easiest way to fix this is to add a image box to the top left (0,0) of the form with its stretch property set to true and put your background picture in that. Then, in the Form_Resize event, set the size of the image box to be the size of the form by adding the code:

Private Sub Form_Resize()
imgBackground.Width = Me.Width
imgBackground.Height = Me.Height
End Sub

Where imgBackground is the name of the image box.

Also move any form_click or form_mouse* events into the imagebox events instead. For example, the code for making the form draggable, which is normally in Form_MouseDown, should instead go in imgBackground_MouseDown.

Alternatively you may not want the form to scale for whatever reason. If you wish to prevent this from happening then you should change the line in the Form_Load event:

nRet = SetWindowRgn(hWnd, CreateFormRegion(1, 1, 0, 0), True)

to:

nRet = SetWindowRgn(Me.hWnd, CreateFormRegion(Screen.TwipsPerPixelX / 15, Screen.TwipsPerPixelY / 15, 0, 0), True)

Note that 15 is only an example value. Depending on your own display settings this may be different. To determine your value look in the CreateFormRegion function at any line starting ObjectRegion = , then look along that line to find a bit which looks like * ScaleX * 15 / Screen.TwipsPerPixelX + OffsetX (and similarly for Y), and the highlighted number is the one you should use.