Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    [Vb6.0] Trascinamento del form

    Ciao ragazzi volevo sapere.. come faccio a far in modo che se con il mous clicco sul form e tenendolo cliccato io possa muovere il form.. non solo dalla barra in alto? spero di essermi spiegato...qualkosa tipo AtomixMp3 che da qualunque parte prendi il form lo trascina dove vuoi..
    g
    r
    a
    s
    s
    i
    e
    W Le Cozze Allattamate

  2. #2
    Utente bannato
    Registrato dal
    Sep 2003
    Messaggi
    1,012
    codice:
    Dim MouseDown_Flag As Boolean
    Dim MouseDownPos_X As Integer
    Dim MouseDownPos_Y As Integer
    
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    MouseDown_Flag = True
    MouseDownPos_X = X
    MouseDownPos_Y = Y
    pt = Me.Top
    pl = Me.Left
    End Sub
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If MouseDown_Flag Then
        Me.Top = Me.Top + (Y - MouseDownPos_Y)
        Me.Left = Me.Left + (X - MouseDownPos_X)
    End If
    End Sub
    
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    MouseDown_Flag = False
    End Sub
    p
    r
    e
    g
    g
    o


  3. #3

    ggrgassie

    grasie mille...
    hai qualke porzione di codice...x far in modo che venga ancorato ai bordi del desktop quando vi è vicino?...tipo winamp?
    W Le Cozze Allattamate

  4. #4
    Utente bannato
    Registrato dal
    Sep 2003
    Messaggi
    1,012
    Prova questo codice: ha il solo difetto che nn puoi uscire dallo schermo

    codice:
    Dim MouseDown_Flag As Boolean
    Dim MouseDownPos_X As Integer
    Dim MouseDownPos_Y As Integer
    
    'Questa modificala quanto vuoi
    'o la puoi mettere nel pannello opzioni del tuo programma
    'se la fai variabile
    Const Arrotonda As Integer = 180 'In twip
    
    
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    MouseDown_Flag = True
    MouseDownPos_X = X
    MouseDownPos_Y = Y
    pt = Me.Top
    pl = Me.Left
    End Sub
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If MouseDown_Flag Then
        Dim iTop As Integer, iLeft As Integer
    
        iTop = Me.Top + (Y - MouseDownPos_Y)
        iLeft = Me.Left + (X - MouseDownPos_X)
        
        If iTop - Arrotonda <= 0 Then
        'In questo caso attacca il form in alto
            iTop = 0
        ElseIf iTop + Arrotonda + Me.Height >= Screen.Height Then
        'In questo caso attacca il form in basso
            iTop = Screen.Height - Me.Height
        End If
        
        If iLeft - Arrotonda <= 0 Then
        'In questo caso attacca il form a sinistra
            iLeft = 0
        ElseIf iLeft + Arrotonda + Me.Width >= Screen.Width Then
        'In questo caso attacca il form a destra
            iLeft = Screen.Width - Me.Width
        End If
        
        Me.Top = iTop
        Me.Left = iLeft
    End If
    End Sub
    
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    MouseDown_Flag = False
    End Sub

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.