mpappert Posted November 17, 2002 Posted November 17, 2002 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 Quote
mpappert Posted November 17, 2002 Author Posted November 17, 2002 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 Quote
*Experts* Volte Posted November 17, 2002 *Experts* Posted November 17, 2002 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.