Results 1 to 12 of 12

Thread: MouseEvents

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    8

    Unhappy

    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.

  2. #2
    Guest
    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    8

    Wink

    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.

  4. #4
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    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.
    -Excalibur

  5. #5
    Guest
    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

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    8
    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.

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    8
    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.

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  10. #10

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    8
    Sure, but my Command-Controls (I have got 30 of them) are initialized at RunTime and I must address them like
    Picture1.Container.

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    8

    Lightbulb 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

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