![Embarassed :oops:](./images/smilies/icon_redface.gif)
Заранее Большое Спасибо.
tyomitch писал(а):Чесслово, сам на этот форум уже не раз кидал этот код... И GSerg кидал... И мы ещё спорили, чей лучше![]()
Option Explicit
Dim sx As Single, sy As Single
Dim dx As Single, dy As Single
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbLeftButton) Then dx = X - sx: dy = Y - sy
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbLeftButton) Then sx = X - dx: sy = Y - dy: Picture1.Refresh
End Sub
Private Sub Picture1_Paint()
Picture1.PaintPicture Picture2, sx, sy
End Sub
Option Explicit
Private Const SRCCOPY = &HCC0020
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private CurX As Single
Private CurY As Single
Private OffsetX As Single
Private OffsetY As Single
Private xmin As Single
Private ymin As Single
Private Dragging As Boolean
Private Sub Form_Load()
'Picture1 - пустая рамка, Picture2 - наша картинка
Me.ScaleMode = vbPixels: Picture1.ScaleMode = vbPixels: Picture2.ScaleMode = vbPixels
Picture1.AutoRedraw = True: Picture1.AutoSize = False
Picture2.AutoRedraw = True: Picture2.AutoSize = False
xmin = Picture1.Width - Picture2.Width
ymin = Picture1.Height - Picture2.Height
CurX = 0
CurY = 0
DrawPicture
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dragging = True
OffsetX = CurX - x
OffsetY = CurY - y
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Not Dragging Then Exit Sub
If Picture2.Width > Picture1.Width Then CurX = x + OffsetX
If Picture2.Height > Picture1.Height Then CurY = y + OffsetY
If CurX > 0 Then CurX = 0
If CurY > 0 Then CurY = 0
If CurX < xmin Then If xmin < 0 Then CurX = xmin
If CurY < ymin Then If ymin < 0 Then CurY = ymin
DrawPicture
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dragging = False
End Sub
Private Sub DrawPicture()
BitBlt Picture1.hDC, CurX, CurY, Picture2.Width, Picture2.Height, Picture2.hDC, 0, 0, SRCCOPY
Picture1.Refresh
End Sub
Sur писал(а):Я понимаю, что для новичков, но такое.....
Сейчас этот форум просматривают: Yandex-бот и гости: 53