[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?
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
Re: MouseMove Trigger not working...
Thing is, I don't need to use any of those parameters. Can I just use vbNull?
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.
Re: MouseMove Trigger not working...
Because I need to simulate the MouseMove event.
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.
Re: MouseMove Trigger not working...
Found it. It is using vbNull in place of the required parameters. Thanks, LaVolpe.
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
Re: MouseMove Trigger not working...
Quote:
Originally Posted by
Conroy Vanderbluff
... 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.