See my previous reply also. In that reply I offered a way to scale the image to your picturebox, but you wanted to offset it, so with slight modifications of the previous post, we have the following
Edited: The +/- offsets must be passed as pixels.Code:Private Sub LoadAndOffset(FileName As String, Destination As VB.PictureBox, xOffset As Long, yOffset As Long) Dim tPic As StdPicture Dim srcCX As Long, srcCY As Long On Error Resume Next Set tPic = LoadPicture(FileName) If Err Then Err.Clear Exit Sub End If On Error Goto 0 With Destination ' the .Cls & .AutoRedraw can be done outside of this routine if desired; does not have to be done here .Cls .AutoRedraw = True End With With tPic srcCX = Destination.ScaleX(.Width, vbHimetric, vbPixels) srcCY = Destination.ScaleY(.Height, vbHimetric, vbPixels) ' Draw to scale. Don't remove the +0& below else errors .Render Destination.hDC, xOffset + 0&, yOffset + 0&, srcCX + 0&, srcCY + 0&, _ 0&, .Height, .Width, -.Height, ByVal 0& End With Destination.Refresh 'this can be called outside of this routine; does not need to be done here End Sub




Reply With Quote