PictureAlignment Property

Applies To

Frame control, Image control, Page object, UserForm object.

Description

Specifies the location of a background picture.

Syntax

object.PictureAlignment [= fmPictureAlignment]

The PictureAlignment property syntax has these parts:

Part

Description

object

Required. A valid object.

fmPictureAlignment

Optional. The position where the picture aligns with the control.


Settings

The settings for fmPictureAlignment are:

Constant

Value

Description

fmPictureAlignmentTopLeft

0

The top left corner.

fmPictureAlignmentTopRight

1

The top right corner.

fmPictureAlignmentCenter

2

The center.

fmPictureAlignmentBottomLeft

3

The bottom left corner.

fmPictureAlignmentBottomRight

4

The bottom right corner.


Remarks

The PictureAlignment property identifies which corner of the picture is the same as the corresponding corner of the control or container where the picture is used.

For example, setting PictureAlignment to fmPictureAlignmentTopLeft means that the top left corner of the picture coincides with the top left corner of the control or container. Setting PictureAlignment to fmPictureAlignmentCenter positions the picture in the middle, relative to the height as well as the width of the control or container.

If you tile an image on a control or container, the setting of PictureAlignment
affects the tiling pattern. For example, if PictureAlignment is set to fmPictureAlignmentUpperLeft, the first copy of the image is laid in the upper left corner of the control or container and additional copies are tiled from left to right across each row. If PictureAlignment is fmPictureAlignmentCenter, the first copy of the image is laid at the center of the control or container, additional copies are laid to the left and right to complete the row, and additional rows are added to fill the control or container.

Note Setting the PictureSizeMode property to fmSizeModeStretch overrides PictureAlignment. When PictureSizeMode is set to fmSizeModeStretch, the picture fills the entire control or container.

See Also

Picture property, PicturePosition property, PictureSizeMode property, PictureTiling property.

Example

The following example uses the PictureAlignment property to set up a background picture. The example also identifies the alignment options provided by PictureAlignment.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

  • A Frame named Frame1.
  • A SpinButton named SpinButton1.
  • A TextBox named TextBox1.
    Dim Alignments(5) As String
    
    Private Sub UserForm_Initialize()
        Alignments(0) = "0 - Top Left"
        Alignments(1) = "1 - Top Right"
        Alignments(2) = "2 - Center"
        Alignments(3) = "3 - Bottom Left"
        Alignments(4) = "4 - Bottom Right"
    
        'Specify a bitmap that exists on your system
        Frame1.Picture = LoadPicture("c:\winnt2\ball.bmp")
        
        SpinButton1.Min = 0
        SpinButton1.Max = 4
        SpinButton1.Value = 0
        
        TextBox1.Text = Alignments(0)
        Frame1.PictureAlignment = SpinButton1.Value
    End Sub
    
    Private Sub SpinButton1_Change()
        TextBox1.Text = Alignments(SpinButton1.Value)
        Frame1.PictureAlignment = SpinButton1.Value
    End Sub
    
    Private Sub TextBox1_Change()
        Select Case TextBox1.Text
        Case "0"
            TextBox1.Text = Alignments(0)
            Frame1.PictureAlignment = 0
        Case "1"
            TextBox1.Text = Alignments(1)
            Frame1.PictureAlignment = 1
        Case "2"
            TextBox1.Text = Alignments(2)
            Frame1.PictureAlignment = 2
        Case "3"
            TextBox1.Text = Alignments(3)
            Frame1.PictureAlignment = 3
        Case "4"
            TextBox1.Text = Alignments(4)
            Frame1.PictureAlignment = 4
        Case Else
            TextBox1.Text = Alignments(SpinButton1.Value)
            Frame1.PictureAlignment = SpinButton1.Value
        End Select
    End Sub