Results 1 to 5 of 5

Thread: [RESOLVED] Weird Problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2005
    Location
    Toronto, Canada
    Posts
    357

    Resolved [RESOLVED] Weird Problem

    Hi,
    I was just trying to make this program for the fun of it... and I wanted to add a clickwheel control to it.
    I am trying to detect the motions by dividing the UserControl (i.e the Clickwheel) into four quarters and there will be two types of motions per quarter. However, for some reason wherever I move the mouse over the UserControl, it always goes to the third If condition (Top Left Quarter)... I am using the following code... if someone can help me.. I would really appreciate it...

    VB Code:
    1. Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2.     Static intX As Integer
    3.     Static intY As Integer
    4.    
    5.     If X > frmMain.linSeperator.X1 Then
    6.         If Y < frmMain.linHSeperator.Y1 Then
    7.             ' "Going Down The List"
    8.             frmMain.Label1.Caption = "1 " & X & " " & Y
    9.             If X > intX And Y > intY Then Call ScrollAdd
    10.             ' "Going Up The List"
    11.             If X < intX And Y < intY Then Call ScrollSubtract
    12.         End If
    13.         If Y > frmMain.linHSeperator.Y1 Then
    14.             frmMain.Label1.Caption = "2 " & X & " " & Y
    15.             ' "Going Up The List"
    16.             If X > intX And Y < intY Then Call ScrollAdd
    17.             ' "Going Down The List"
    18.             If X < intX And Y > intY Then Call ScrollSubtract
    19.         End If
    20.     End If
    21.     If X < frmMain.linSeperator.X1 Then
    22.         If Y < frmMain.linSeperator.Y1 Then
    23.             frmMain.Label1.Caption = "3 " & X & " " & Y
    24.             ' "Going Down The List"
    25.             If X > intX And Y < intY Then Call ScrollAdd
    26.             ' "Going Up The List"
    27.             If X < intX And Y > intY Then Call ScrollSubtract
    28.         End If
    29.         If Y > frmMain.linSeperator.Y1 Then
    30.         frmMain.Label1.Caption = "4 " & X & " " & Y
    31.             ' "Going Up The List"
    32.             If X > intX And Y > intY Then Call ScrollSubtract
    33.             ' "Going Down The List"
    34.             If X < intX And Y < intY Then Call ScrollAdd
    35.         End If
    36.     End If
    37.  
    38.     intX = X
    39.     intY = Y

    If you want to take a look at the project... I have attached it... I have just begun... so it isn't that great...

    Any help would be appreciated.
    Khanjan
    Attached Files Attached Files
    Hey... If you found this post helpful please rate it.

  2. #2
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    415

    Re: Weird Problem

    Get rid of the linSeperator/linHSeperator, use (UserControl.ScaleHeight/2) instead
    Ie:

    VB Code:
    1. Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2.     Static intX As Integer
    3.     Static intY As Integer
    4.  
    5.     If X > (UserControl.ScaleWidth / 2) Then
    6.         If Y < (UserControl.ScaleHeight / 2) Then
    7.             ' "Going Down The List"
    8.             frmMain.Label1.Caption = "1 " & X & " " & Y
    9.             If X > intX And Y > intY Then Call ScrollAdd
    10.             ' "Going Up The List"
    11.             If X < intX And Y < intY Then Call ScrollSubtract
    12.         End If
    13.         If Y > (UserControl.ScaleHeight / 2) Then
    14.             frmMain.Label1.Caption = "2 " & X & " " & Y
    15.             ' "Going Up The List"
    16.             If X > intX And Y < intY Then Call ScrollAdd
    17.             ' "Going Down The List"
    18.             If X < intX And Y > intY Then Call ScrollSubtract
    19.         End If
    20.     End If
    21.     If X < (UserControl.ScaleWidth / 2) Then
    22.         If Y < (UserControl.ScaleHeight / 2) Then
    23.             frmMain.Label1.Caption = "3 " & X & " " & Y
    24.             ' "Going Down The List"
    25.             If X > intX And Y < intY Then Call ScrollAdd
    26.             ' "Going Up The List"
    27.             If X < intX And Y > intY Then Call ScrollSubtract
    28.         End If
    29.         If Y > (UserControl.ScaleHeight / 2) Then
    30.             frmMain.Label1.Caption = "4 " & X & " " & Y
    31.             ' "Going Up The List"
    32.             If X > intX And Y > intY Then Call ScrollSubtract
    33.             ' "Going Down The List"
    34.             If X < intX And Y < intY Then Call ScrollAdd
    35.         End If
    36.     End If
    37.  
    38.     intX = X
    39.     intY = Y
    40. End Sub

  3. #3
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Weird Problem

    Can't check it, since I'm at work, but what are intX and intY for?
    They are locally declared as Static, and you set them at the end of the sub? What should their value be before, remember you use them in the If -clauses!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2005
    Location
    Toronto, Canada
    Posts
    357

    Re: Weird Problem

    intX and intY are for storing the previous co-ordinates. So I can match the current X and Y co-ordinates of the mouse and figure out in which direction the mouse is moving...
    Hope that helps

    Rob I will be trying your suggestion and I will reply to inform if it works or not.
    Thank you,

    Khanjan
    Hey... If you found this post helpful please rate it.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2005
    Location
    Toronto, Canada
    Posts
    357

    Re: Weird Problem

    Thanx Rob123, your code works. I really appreciate it.

    Khanjan
    Hey... If you found this post helpful please rate it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width