Results 1 to 6 of 6

Thread: Intercepting events

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Westminster, Md.
    Posts
    163
    Is there a way I can intercept a form based event from inside a usercontrol?

    Ie: Snag the mouse move event for the form from inside a usercontrol?


    EireDrake

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Are you making a rollover effect?
    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.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Westminster, Md.
    Posts
    163

    Roll over

    Basically I'm trying to detect when the mouse is over the control or over the form from within the control...

    I'm basically trying to create a Command Button which highlights it's text when the cursor is over it OR changes it's image when the cursor is over it.

    And yes I know that there are controls already out there but I have some specifications I want in the control. So what I need to be able to do is detect when the Mouse Cursor is no longer over the control in order to let the control know when to switch back. I'd prefer to avoid using the mouse API's because I don't feel like having to compute the control position based on the screen.

    Ie: Usercontrol_Mouse_Move(blah)
    Text1.forecolor=VBRED
    end

    Form1_Mouse_Move(Blah)
    text1.forecolor=VBBLACK
    end

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I'm confused... Why would you like to avoid api as i have the perfect solution for you, using it?
    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.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Westminster, Md.
    Posts
    163

    API

    Don't get me wrong... ANY solution is better than no solution. I was just hoping there was a way to do it without an API...Whatcha got? I'll put it to use if it's what I'm looking for...

    Thanks,
    EireDrake


  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Of course you can do it without api, but never as a usercontrol, you have to subclass and ****.

    No, you have to get the mouseposition and the usercontrol wnd's Rect. using these:
    Code:
    Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
    Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Long, lpRect As RECT) As Long
    Type POINTAPI
            x As Long
            y As Long
    End Type
    Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End Type
    Get the wnd of your usercontrol and get it's rect, then get the mousecursor pointapi and compare the it with the rect and see if they fit, if not, you're mouse exiting - this has to be done in a timer. Turn of the timer when your mouse exits and when it enters by triggering mousemove event, you enable the timer again.
    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.

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