Results 1 to 10 of 10

Thread: Mouse over ocx's

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    21
    I am trying to make a ocx which changes one image to another on mouse over and back to the original on mouse out. I have no idea how to make a control so if anyone can help me?

  2. #2
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    Do you need help with the code or actually making a control?

    To make a control:
    In vb6 (if you don't have vb6 then Im not sure) open a new activeX project.


  3. #3
    Guest
    It's supported in both VB5 and 6. The actual name of the project template is ActiveX Control.

  4. #4
    Addicted Member Michel Jr's Avatar
    Join Date
    Jan 2000
    Location
    Brazil
    Posts
    175

    Talking I have the OCX you need

    Hi Jon,

    Take a look at my Home Page.
    There is an OCX that I developed and it is available there. It has all the resources you need, and a lot of other good resources.
    Just download MJButton-Share.zip and try it. Feel free to download the others OCX and evaluate them too.

    I hope you enjoy it.

    Michel Jr.

    http://www.geocities.com/michel_junior_hp/index.html

  5. #5
    Addicted Member
    Join Date
    May 2000
    Location
    Westminster, Md.
    Posts
    163

    mOUSE OVER

    Perhaps, much like myself, our friend wants to create the control on his own....


    "Trust no one" is a safer bet. Unless of course the person is willing to give their source, who knows what all stuff they stuck in there. It'd be pretty easy for the unscrupulous to stick in code that'd completely fry your system and you'd never notice it until the magic smoke started coming out. (IE: An API call to park the HDD while it is still spinning=Need a new HDD)



    Basically you're going to need to keep track of the mouse position. When it's over the control execute one thing, when the mouse is not over the control do another.

    Easiest way to do this without a custome control is to have a Mouse_Move event on the stock button control that Does X and then a Mouse_Move event in the Form itself that does Y when the mouse is over it.

    After looking into this myself, the only other way I was able to find to do this was to basically create a timer within the form (which API's can be used for) that will continually ask the mouse 'Where are you?' Then if the Mouse replies "I am within the Boundaries of this control" you have the new picture/text pop in.

    The only other way I could think of that'd possible work would be to create a region around the control using APIs and monitor it. However I have no clue how to do it, just that it might be possible. I'm still waiting on the $40 to spare on Dan Appleman's API book.

    Good luck with this, cuz it's a real PITA. I'd be willing to share the source that I myself have come up with if you like.

    Eiredrake

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    21
    thanks all of you... a souce code would help me out a lot

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Set a timer in the form, and every 100ms or so, check (using GetCursorPos) whether it is inside the control (GetWindowPos helps here).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Why not try this :

    1. Use the Mouse_Move event to alter the picture to the "hover" image. Also Enable the timer at this point

    2. When the timer goes off you can simply check to see if the mouse is still over the control, if it is you do nothing. If it isn't you turn the picture back to normal and DISABLE the timer



    By doing it this way the timer will only be an issue for the period of time you are on the control and not ALL the time having to check. When it is successful in turning it back to normal you don't need to run the timer again.

    Hope it helps

  9. #9
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386
    Use the SetCapture API when the mouse is over the control. That way, *all* mousemove's etc are send to your control.
    When the x or the y is below 0 or are higher then the width and height then you know it's no longer above the control and you can call ReleaseCapture.
    Hope this helps

    Crazy D

  10. #10
    Junior Member
    Join Date
    Jul 2000
    Location
    Belfast
    Posts
    28
    Use the following code with the BitBlt function and a picture box.
    You will need to chang ethe values etc. as this is just cut and pasted from a project of my own.

    [code]
    Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Public Declare Function GetCapture Lib "user32" () As Long
    Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Public Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
    Public Declare Function ReleaseCapture Lib "user32" () As Long

    Private Sub picActPor_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    Dim ret As Long

    If GetCapture() <> picActPor.hWnd Then
    ret = SetCapture(picActPor.hWnd)
    Call BitBlt(picActPor.hDC, 0, 0, 38, 8, picSourceImage.hDC, 476, 38, SRCCOPY)

    'Button Higlight
    picActPor.Refresh
    End If

    If X > 0 And X < picActPor.Width And Y > 0 And Y < picActPor.Height Then
    CurrentX = X
    CurrentY = Y
    Else
    If GetCapture() = picActPor.hWnd Then
    ret = ReleaseCapture()
    Call BitBlt(picActPor.hDC, 0, 0, 38, 38, picSourceImage.hDC, 476, 0, SRCCOPY)

    'Button Nornal
    picActPor.Refresh
    End If
    End If

    End Sub

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