Oppure

Loading
23/01/10 11:33
foralobo
salve a tutti eccomi di nuovo con un altro problema...

dato un form, vorrei potere spostarlo cliccandoci sopra e trascinandolo...mi direte clicca sulla bara del titolo...ebbene voglio spostare il form che ha come borderstyle = 0 ovvero non ha barra del titolo...

iccome vorrei fare un'interfaccia disegnata, devo eliminare la barra e alla necessità spostare il form cliccando su una parte precisa del form...

ho cercato un po tra gli eventi DragDrop ma l'msnd mi da errore se cerco questi eventi...non so neanche se siano quelli corretti..

mi aiutate?

grazie
aaa
23/01/10 12:03
Louis
Così dovresti risolvere:

Option Explicit

Const HTCAPTION = 2
Const WM_NCLBUTTONDOWN = &HA1
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, lParam As Long) As Long
'--------------------------------
Private Sub Form_Load()
    Me.BorderStyle = 0
End Sub
'--------------------------------
' Sposta con il mouse una Form senza bordo BorderStyle = 0:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, _
        x As Single, Y As Single)
    If Button = 1 Then
        Dim ReturnVal As Long
        x = ReleaseCapture()
        ReturnVal = SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
    End If
End Sub

:k:
aaa
23/01/10 12:05
DavidP
prova questo codice:
Const HTCAPTION = 2
Const WM_NCLBUTTONDOWN = &HA1
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, lParam As Long) As Long

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, _
        x As Single, Y As Single)
    If Button = 1 Then
        Dim ReturnVal As Long
        x = ReleaseCapture()
        ReturnVal = SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
    End If
End Sub


@Luis
Per 1 secondo
Ultima modifica effettuata da DavidP 23/01/10 12:06
aaa
23/01/10 12:16
Louis
Pazienza, non ti preoccupare :)
aaa
23/01/10 12:28
DavidP
Va be fa niente
aaa
25/01/10 11:46
foralobo
grazie tante...l'ho trovato anche io q1uesto codice... ma volevo risolvere senza utilizzare le api...qualche idea?
aaa
25/01/10 13:12
Alfonso
Dim yTop As Long
Dim xLeft As Long
Dim Trascinamento As Boolean

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)

 If Trascinamento = False Then
    Screen.MousePointer = 5
    Trascinamento = True
    yTop = Y
    xLeft = x
 End If

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)

  If Trascinamento = True Then
    Me.Top = Me.Top + Y - yTop
    Me.Left = Me.Left + x - xLeft
  End If

End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)

  If Trascinamento Then
    Trascinamento = False
    Screen.MousePointer = 1
  End If

End Sub


Ciao
aaa