| ' Make the button display the picture beneath it.
Private Sub SetButtonBackground(ByVal btn As CommandButton)
Dim wid As Single
Dim hgt As Single
Dim xoff As Single
Dim yoff As Single
    ' Get the button size.
    wid = btn.Width
    hgt = btn.Height
    ' Get the button's border thickness.
    xoff = GetSystemMetrics(SM_CXFIXEDFRAME)
    yoff = GetSystemMetrics(SM_CYFIXEDFRAME)
    ' Size the hidden PictureBox to fit the button.
    picHidden.Move 0, 0, wid, hgt
    ' Copy the picture under the button to the PictureBox.
    picHidden.PaintPicture Picture, 0, 0, wid, hgt, _
        btn.Left + xoff, btn.Top + yoff, wid, hgt
    picHidden.Picture = picHidden.Image
    ' Set the button's picture.
    btn.Picture = picHidden.Picture
End Sub |