Results 1 to 9 of 9

Thread: [RESOLVED] MouseMove Trigger not working...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Resolved [RESOLVED] MouseMove Trigger not working...

    I have an array of PictureBoxes that has code in both the Click and MouseMove events. I am able to trigger the Click event with
    Code:
    picPicture_Click (i)
    ...but

    Code:
    picPicture_MouseMove (i)
    doesn't seem to work. I get an "Argument not optional", highlighting picPicture_MouseMove. Any ideas how I can trigger the MouseMove event?

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: MouseMove Trigger not working...

    Look at the picturebox's actual MouseMove event. You'll see that there are more than 1 parameter that the event is expecting. You must provide every parameter unless the parameter is specifically tagged as Optional
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: MouseMove Trigger not working...

    Thing is, I don't need to use any of those parameters. Can I just use vbNull?

  4. #4
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,598

    Re: MouseMove Trigger not working...

    If you don't need any of those parameters, why call it at all.
    Why not create a new sub, move the code you have in your MouseMove event to it, and have both your MouseMove event handler and your other code call the new sub.
    Same with the MouseClick.

    If you ever feel the need to call an event handler from your code that should be a red flag. Copy the code to a new meaningful named sub, and call it from your event handler and anywhere else you feel the need.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: MouseMove Trigger not working...

    Because I need to simulate the MouseMove event.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: MouseMove Trigger not working...

    Wrong. It is not a red flag, and here's why:
    When the user moves the mouse over the PictureBox, a truckload of code fires. Having said that, I would like a "demo" to be performed, therefore firing the MouseMove event is required. Copying the code into an entirely new sub would only enlarge the filesize, which is not something I want and is also frowned upon by most programmers and users alike. If you have an answer that fits the parameters of my original question and does not answer it with questions that stray from the request, please feel free to provide it.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: MouseMove Trigger not working...

    Found it. It is using vbNull in place of the required parameters. Thanks, LaVolpe.

  8. #8
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [RESOLVED] MouseMove Trigger not working...

    FYI: vbNull is not the same as NULL. vbNull is a VB constant with a value that is not zero
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  9. #9
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,598

    Re: MouseMove Trigger not working...

    Quote Originally Posted by Conroy Vanderbluff View Post
    ... Copying the code into an entirely new sub would only enlarge the filesize, which is not something I want and is also frowned upon by most programmers and users alike...
    I didn't say copy the code, I said move the code, so the size of the file wouldn't change much at all.

    I was just saying if you had your code in a sub your wrote, you wouldn't need to know all the parameters of the event handler to call it.
    Some code below pulled from an old project.
    If I wanted to simulate what calling the MouseUp event handler would do in my code, I would just call the UnHiLight_the_HiLighted_Card sub.
    Since I don't care about any of the parameters in the MouseUp event handler, I don't need to look it up to see how many parameters there are and call it with dummy placeholder, I just call the sub the event handler calls.
    Code:
    Private Sub Form_Load()
      Initialize_Everything
    End Sub
    
    Sub picDest_MouseUp(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
      UnHiLight_the_HiLighted_Card
    End Sub
    
    Sub cmdUndo_Click()
      Undo_a_Move
    End Sub
    It can also make it more convenient to look at the code from a top level. You can see more of the event handlers together on a page and scroll up and down through them quickly, and if you have the subs in another file, when you put the cursor on the sub in the event you interested in and press Shift-F2, the code pops up in another window so you can look at it without loosing your place in the window that has the event handlers.
    Just trying to make your life a little simpler, no biggie.

Tags for this Thread

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