Ver Mensaje Individual
  #2 (permalink)  
Antiguo 20/04/2011, 17:58
truskyvb
 
Fecha de Ingreso: octubre-2008
Mensajes: 188
Antigüedad: 15 años, 7 meses
Puntos: 3
Respuesta: Problemas con Picturebox

Lo encontré hace tiempo y creo que hace lo que necesitas.
Espero que te sirva.

Option Explicit

'Initial bounding box position and size. The width and height are the
'size of the picture control holding the Canadian flag image.
Const INIT_BBOX_LEFT = 64
Const INIT_BBOX_TOP = 64
Const INIT_BBOX_WIDTH = 217
Const INIT_BBOX_HEIGHT = 145

'States to track dragging.
Const WAITING = 0
Const DRAGGING = 1

'Names for hot spots, with a different kind of drag for each. DON'T
'CHANGE -- used as array indices in the Cursor() array, return values
'from PtinHotSpot(), and elsewhere. Stored in global variable hs.
Const TOP_LEFT = 0
Const TOP_MID = 1
Const TOP_RT = 2
Const MID_RT = 3
Const BOT_RT = 4
Const BOT_MID = 5
Const BOT_LEFT = 6
Const MID_LEFT = 7
Const TRANSLATE = 8
Const NO_HIT = 9

'The following three constants determine the size of the little black
'boxes and their distance from the bounding box. The size of the little
'boxes is one more than BOXSIZE; HALF_BOXSIZE is half of that; and
'MARGIN = BOXSIZE + 1 + (number of pixels between the bbox and the
'little boxes). Here the boxes are 5 pixels square and they are 2 pixels
'from the bbox -- resetting to (6, 3, 8) respectively gives boxes 7
'pixels square and 1 pixel from the bbox.
Const BOXSIZE = 4
Const HALF_BOXSIZE = 2
Const MARGIN = 7

'Type for bounding box holding image.
Private Type box
Left As Integer
Top As Integer
width As Integer
height As Integer
End Type

'16-bit Windows (Win31) and 32-bit Windows (Win95 / WIN NT) have
'different type and function declarations. Use conditional compilation
'to compile either way, depending on which VB compiler is being used.

#If Win32 Then

'WinAPI RECT for ClipCursor().
Private Type RECT
x1 As Long
y1 As Long
x2 As Long
y2 As Long
End Type

'WinAPI POINT for ClientToScreen().
Private Type wpoint
x As Long
y As Long
End Type

'WinAPI calls for restricting cursor.
Private Declare Sub ClipCursor Lib "User32" (r As RECT)
Private Declare Sub ClearCursor Lib "User32" Alias "ClipCursor" (ByVal lpr&)
Private Declare Sub ClientToScreen Lib "User32" (ByVal hwnd As Long, lpp As wpoint)

#Else

'WinAPI RECT for ClipCursor().
Private Type RECT
x1 As Integer
y1 As Integer
x2 As Integer
y2 As Integer
End Type

'WinAPI POINT for ClientToScreen().
Private Type wpoint
x As Integer
y As Integer
End Type

'WinAPI calls for restricting cursor.
Private Declare Sub ClipCursor Lib "User" (r As RECT)
Private Declare Sub ClearCursor Lib "User" Alias "ClipCursor" (ByVal lpr&)
Private Declare Sub ClientToScreen Lib "User" (ByVal hwnd%, lpp As wpoint)

#End If

'Bounding box holding image.
Dim Bbox As box

'Array of cursors for each hot spot.
Dim Cursor%(NO_HIT)

'State variable to track drag.
Dim State%

'Hot spot index.
Dim hs%

'Mouse deltas relative to bbox top left (used to translate).
Dim dx%, dy%