Gobillot
Messages postés
3140
Date d'inscription
vendredi 14 mai 2004
Statut
Membre
Dernière intervention
11 mars 2019
34
31 déc. 2005 à 21:54
Bonjour
désolé, les bases de donnée et Access je ne connais pas
j'ai tout refait le traitement.
un pointeur par contrôle, ici un PictureBox et un CommandButton
contrôle Resizable et Déplaçable, y compris la Forme elle même.
Option Explicit
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Private Type POINTAPI
X As Long
Y As Long
End Type
Dim posX As Long
Dim posY As Long
Dim XX As Long
Dim YY As Long
Dim Pointer1 As Long
Dim Pointer2 As Long
Private Declare Function SendMessage Lib "User32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam
As Any) As Long
Private Declare Sub ReleaseCapture Lib "User32" ()
Private Declare Function GetCursorPos Lib "User32" (lpPoint As POINTAPI) As Long
Private Declare Function GetAsyncKeyState Lib "User32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Me.ScaleMode = 3
Timer1.Interval = 10
Timer1.Enabled = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim P As Long
P = Pointer1 + Pointer2
If Button = 1 Then TestDeplacement P, Me
' Picture1.BorderStyle = 0
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then TestDeplacement Pointer1, Command1
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then TestDeplacement Pointer2, Picture1
End Sub
Private Sub Timer1_Timer()
Dim pt As POINTAPI
GetCursorPos pt
posX = pt.X - Me.Left / 15 - 4
posY = pt.Y - Me.Top / 15 - 30
If GetAsyncKeyState(1) < 0 Then
TestResizer Pointer1, Command1
TestResizer Pointer2, Picture1
Else
TestPointer Pointer1, Command1
If Pointer1 > 0 Then Exit Sub
TestPointer Pointer2, Picture1
If Pointer2 > 0 Then Exit Sub
End If
End Sub
Private Sub TestPointer(pointer As Long, obj As Control)
Dim zX As Long
Dim zY As Long
pointer = 0
zX = posX - obj.Left
zY = posY - obj.Top
If zX > 0 And zX < obj.Width + 20 And _
zY > 0 And zY < obj.Height + 20 Then
' obj.BorderStyle = 1
If zX > obj.Width - 20 Then
XX zX: pointer 9
End If
If zY > obj.Height - 20 Then
YY zY: If pointer 0 Then pointer = 7 Else pointer = 8
End If
End If
obj.MousePointer = pointer
End Sub
Private Sub TestResizer(pointer, obj As Control)
Dim zX As Long
Dim zY As Long
Dim d As Long
If pointer 9 Or pointer 8 Then
zX = posX - obj.Left
d = obj.Width + zX - XX
If d > 20 And d < Me.ScaleWidth Then obj.Width d: XX zX
End If
If pointer 7 Or pointer 8 Then
zY = posY - obj.Top
d = obj.Height + zY - YY
If d > 20 And d < Me.ScaleHeight Then obj.Height d: YY zY
End If
End Sub
Private Sub TestDeplacement(pointer, obj As Object)
If pointer = 0 Then
Call ReleaseCapture
SendMessage obj.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End If
End Sub
joyeuses fêtes
Daniel