Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey Everyone,

 

I'm working on creating a custom form layout (basically replace the default TitleBar with one of my own creations) .. I'm having problems with tracking mouse events ... It moves but the form moves 'jittery' and when you do a small movement and stop (not releasing the mouse button) the form still jitters until you let go of the mouse. It's also very slow ... here is my code, am I missing something?

 

TIA!

M.

 

 

 

   Private blnMouseDown As Boolean
   Private MouseLocXonClick As Integer
   Private MouseLocYonClick As Integer

   Private Sub lblTitleBar_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
    Handles lblTitleBar.MouseDown

       blnMouseDown = True
       MouseLocXonClick = e.X
       MouseLocYonClick = e.Y

   End Sub


   Private Sub lblTitleBar_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
    Handles lblTitleBar.MouseMove

       If blnMouseDown Then

           Me.Left = e.X - MouseLocXonClick
           Me.Top = e.Y - MouseLocYonClick

       End If

   End Sub


   Private Sub lblTitleBar_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
    Handles lblTitleBar.MouseUp

       blnMouseDown = False

   End Sub

Posted

Man, just as I post I figured it out! LOL .. Anyways, for anyone else wanting to do this .. here is the code that works .. :)

 

M.

 

 

 

   Private blnMouseDown As Boolean
   Private MouseLocXonClick As Integer
   Private MouseLocYonClick As Integer

   Private Sub lblTitleBar_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
    Handles lblTitleBar.MouseDown

       blnMouseDown = True
       MouseLocXonClick = e.X
       MouseLocYonClick = e.Y

   End Sub


   Private Sub lblTitleBar_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
    Handles lblTitleBar.MouseMove

       If blnMouseDown Then

           Me.Left = Me.Left + (e.X - MouseLocXonClick)
           Me.Top = Me.Top + (e.Y - MouseLocYonClick)

       End If

   End Sub


   Private Sub lblTitleBar_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
    Handles lblTitleBar.MouseUp

       blnMouseDown = False

   End Sub

  • *Experts*
Posted

Try replacing the MouseMove code with this:

    Private Sub lblTitleBar_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
    Handles lblTitleBar.MouseMove

       If blnMouseDown Then

           Me.Location = New Drawing.Point(Me.Location.X + (e.X - MouseLocXonClick), _
                                           Me.Location.Y + (e.Y - MouseLocYonClick))
       End If

   End Sub

 

edit: well, I guess you figured it out on your own.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...