Help With MouseMove on a Form

vb6 Canada
  • 19 years ago

    Hi everyone.


    My question is:


    I have a feature on my program that allows it to mimic the Windows StartBar by making it a height of "100" and placing it with a Left position of 0 and a Top position of 0 (top left corner of the screen). What I'm trying to accomplish is that when the user puts the mouse over the program (which would be at a height of "100") it would expand to it's original height ("525") but when they move their mouse off of the program it would return to a height of "100". Anyways, here's what I got:



    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
       ' Dont worry about this line. Just checks if the feature has been activated.
       If frmMenus.mnuStartBarMirror.Checked = True Then
           If frmMain.Height = "100" Then
               frmMain.Height = "525"
           ElseIf frmMain.Height = "525" And X <> frmMain.CurrentX And Y <> frmMain.CurrentY Then
               frmMain.Height = "100"
           End If
       End If
    End Sub




    This works fairly well, however it's a bit jumpy and shaky when you move your mouse around the program and it's really difficult to control. Anyways, I was wondering if anyone knows a way to code this that's easier and more efficient.


    Thanks again guys. You've done an excellent job so far helping me with my problems.

  • 19 years ago

    Instead of using
    X <> frmMain.CurrentX
    which means if the user moves the mouse 1 pixel, the item resizes again, how about


    ((X > frmMain.CurrentX + 5) Or (X < frmMain.CurrentX - 5) )


    the same goes for the Y part...  I don't know whether it will work or not, but it might ....

  • 19 years ago

    That codes works perfect, except for one thing:


    There are a few images on the form and whenver I move my mouse over them it just goes back to a height of "100". Any suggestions?

  • 19 years ago

    In those images mousemove event, make a call to the form's mousemove event... with all the same data....and see if that works.

  • 19 years ago

    Alright, thanks for all the help. But I tried that and all it gives me is 'Compile Error: Argument Not Optional'. Any thoughts?

  • 19 years ago

    You need to give the Form_MouseMove procedure the parameters it normally has:


    Form_MouseMove Button, Shift, X, Y


    These values can be passed from the other control's MouseMove event

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is anticipated with distaste, performed with reluctance, and bragged about forever.” - Dan Kaminsky