Option Explicit Private u As Single, v As Single Private Sub pBox_MouseDown(b As Integer, m As Integer, x As Single, y As Single) If b 1 Then u x: v = y End Sub Private Sub pBox_MouseMove(b As Integer, m As Integer, x As Single, y As Single) If b = 1 Then pBox.Left = pBox.Left + x - u pBox.Top = pBox.Top + y - v Me.Width = pBox.Left + pBox.Width Me.Height = pBox.Top + pBox.Height End If End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionIl n'y a pas de problème si les ScaleMode du formulaire et du PictureBox sont identiques
de quel sexe sont les PictureBox
Je n'ai pas essayé, mais si je le faisais je n'oublierais pas de multiplier Me.Width et Me.Height par le nombre de twips par pixels
Option Explicit Private Type POINTAPI X As Long Y As Long End Type Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long Private rectan0 As RECT Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 2 Then GetWindowRect Me.hwnd, rectan0 SetCursorPos rectan0.Right, rectan0.Bottom End If End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim ou As POINTAPI, rectan0 As RECT If Button = 2 And X > 0 And Y > 0 Then GetCursorPos ou GetWindowRect Me.hwnd, rectan0 MoveWindow Me.hwnd, rectan0.Left, rectan0.Top, ou.X - rectan0.Left, ou.Y - rectan0.Top, 1 End If End Sub
Pas si simple que celà car sous VB la position du form est en twips et ses dimensions en unités de l'échelle choisie.