Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Aug 2004
    Messaggi
    343

    [vb6] Muovere un controllo col mouse

    Ciao a tutti, ho un problema che mi sta facendo diventare matto.
    Voglio fare in modo che l'utente del mio programma possa muovere liberamente alcuni controlli presenti in una finestra, un po' come quando noi programmatori con VB spostiamo i vari controlli inseriti nel form tenendo premuto il tasto sinistro e muovendo il mouse... L'evento corretto credo sia il mousedown, ma poi.....come si fa?
    Grazie in anticipo!
    Ste

  2. #2
    Utente di HTML.it L'avatar di Boolean
    Registrato dal
    Oct 2005
    Messaggi
    758
    ad esempio con una Label posta su un Form:

    codice:
    'nella sezione dichiarazioni
    Dim StartX As Integer, StartY As Integer, Moving As Boolean
    '_________________________________________________________
    
    Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button <> 1 Then Exit Sub
    StartX = X
    StartY = Y
    Moving = True
    Label1.BorderStyle = 1
    End Sub
    
    Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Not Moving Then Exit Sub
    With Label1
        .Move .Left + (X - StartX), .Top + (Y - StartY)
    End With
    End Sub
    
    Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Moving = False
    Label1.BorderStyle = 0
    End Sub
    Boolean

  3. #3
    Utente di HTML.it
    Registrato dal
    Aug 2004
    Messaggi
    343
    Grazie mille boolean, va alla grande!
    Ciao!
    Ste

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.