|
-
Aug 14th, 2000, 03:34 AM
#1
Thread Starter
Junior Member
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?
-
Aug 14th, 2000, 09:24 AM
#2
Frenzied Member
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.
-
Aug 14th, 2000, 09:36 AM
#3
It's supported in both VB5 and 6. The actual name of the project template is ActiveX Control.
-
Aug 14th, 2000, 11:43 AM
#4
Addicted Member
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
-
Aug 14th, 2000, 01:49 PM
#5
Addicted Member
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
-
Aug 14th, 2000, 02:41 PM
#6
Thread Starter
Junior Member
thanks all of you... a souce code would help me out a lot
-
Aug 14th, 2000, 03:08 PM
#7
Monday Morning Lunatic
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
-
Aug 14th, 2000, 06:44 PM
#8
Hyperactive Member
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
-
Aug 15th, 2000, 03:12 AM
#9
Hyperactive Member
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.
-
Aug 15th, 2000, 04:29 AM
#10
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|