-
Okay, because nobody read my last Question I will have a new try:
I want to ignore a MouseEvent with a first control. Instead a second control, that lays under the first, should get this Event.
In C++ its called to 'sink' an Event, but I need this in VisualBasic.
Thanx for your attention.
-
Add the following to a Form with a PictureBox and CommandButton. Make sure the PictureBox overlaps the CommandButton.
Code:
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Print "Mouse moved over button"
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (X + Picture1.Left) > Command1.Left And (Y + Picture1.Top) < (Command1.Height + Command1.Top) Then
Print "Mouse movd over button (through PictureBox)"
End If
End Sub
-
Nice trick, Megatron, but it doesn't solve my problem.
I have about 30 Frame-Objects and about 20 Picture-Boxes on the form and every single Picture can be dragged into a frame.
When the frame gets an DragDrop-Event, it checks, if this picture is allowed to enter and then moves the picture.
Now if I drag on of the pictures over another picture, the PictureBox-Object gets the DragDrop-Event that should be handled by the Frame-Object.
I would prefer the elegant solution to sink the DragDrop-Event to the frame instead of working around.
-
Here is an updated Picture1_MouseMove that should be a bit more accurate:
Code:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form1.Cls
If (X + Picture1.Left > Command1.Left And Y + Picture1.Top > Command1.Top) And _
(X + Picture1.Left < Command1.Left + Command1.Width) And _
(Y + Picture1.Top < Command1.Top + Command1.Height) Then
Print "Mouse moved over button (through PictureBox)"
Else
Print "Mouse Moved over Picturebox"
End If
End Sub
Nifty Idea on how to handle this problem though.
-
Or:
Code:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (X + Picture1.Left) > Command1.Left And (Y + Picture1.Top) < (Command1.Height + Command1.Top) Then
Print "Mouse movd over button (through PictureBox)"
Exit Function
End If
Print "Mouse moved over PictureBox"
End Sub
-
Yes, but I do not want to recognize MouseMove.
I want to perform a DragDrop-Operation on Command1 and by the way, Picture1 is in front of Command1 and is always 100% inside of Command1.
Its a bit tricky thats why I am looking for any way to ignore picture1 completly when an DragDrop-Event occurs.
For now I made Command1 big enough to perform my operation outside picture1, but its only a dirty trick.
-
I'm not sure what youre doing, but i guess youre dragging the picture1 with the mouse, and not using the implemented Drag methods. Am i correct? Then you want to fire the mousemove event on the parent control?
-
I am dragging a Picture2 with the implemented Drag methods. The Command1 sets a zone within where droping Pictures is allowed. But when I drop a Picture3 over Picture1, Picture1 gets the DragDrop-Event instead of Command1.
I want Picture1 to ignore the event and/or send it to Command1.
-
Maybe you could just pass the parameters to the command button drop event instead
Code:
Private Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
Command1_DragDrop Source, X, Y
End Sub
-
Sure, but my Command-Controls (I have got 30 of them) are initialized at RunTime and I must address them like
Picture1.Container.
-
Why don't you create a control array instead? You could as well use load statement to create the rest 29 of them if you have the first item, and you wlil have the same event
-
Solved, thanx to all
Okay, thanx to everyone who helped.
I was so hard trying to find an gobal Ignore-Statement that I haven`t thought about calling the implemented function in my class. I had to make it public
Now the call looks like:
Code:
call spielfeld.spiel.raeume _(Picture.Container.Tag).Raumhandle_DragDrop(Source, X, Y)
'Picture.container.Tag contains the number of the Room (Frame-Object) which contains the picture.
Raumhandle is the variable for the frame within the Rooms.
Its not elegant but it works. In my second project I will think a bit longer about the structure of my classes ;)