Jump to content
×
×
  • Create New...

Déplacer une Fenêtre sans Bordure


Recommended Posts

Niveau requis Débutant

Temps estimé : 15 minutes

Bonjour,

 

Pour déplacer une form ayant la propriété FormBorderStyle à None, il faut utiliser le code suivant :

 

Révélation

 

Code :

Private IsFormBeingDragged As Boolean = False
Private MouseDownX As Integer
Private MouseDownY As Integer
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown

If e.Button = MouseButtons.Left Then
  IsFormBeingDragged = True
    MouseDownX = e.X
    MouseDownY = e.Y
  End If
End Sub

Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp
  If e.Button = MouseButtons.Left Then
      IsFormBeingDragged = False
  End If
End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
  If IsFormBeingDragged Then

    Dim temp As Point = New Point()

    temp.X = Me.Location.X + (e.X - MouseDownX)
    temp.Y = Me.Location.Y + (e.Y - MouseDownY)
    Me.Location = temp
    temp = Nothing
  End If
End Sub

Vous n'avez qu'a ajouter ce code dans votre class Form1 !

 

 

Cordialement,

ThanosS

Link to comment
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

  • 3 months later...
  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Flux d'Activité

    1. 8

      Canal général

    2. 8

      Canal général

    3. 8

      Canal général

    4. 8

      Canal général

    5. 8

      Canal général

    6. 8

      Canal général

    7. 8

      Canal général

    8. 8

      Canal général

    9. 8

      Canal général

  • Recently Browsing

    No registered users viewing this page.

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.