|
-
Apr 18th, 2000, 02:52 AM
#1
Thread Starter
Addicted Member
I have typed and typed, till the tissue of my finger tips have been exposed. I have moaned, groaned, and on several occassions I had come close to posting a significant amount of money as a reward for my answer. Neither My annoying reposts or persistance seem to yeild a termination to my insanity. Luckily with clever use of Cut n Paste, I have been able to overlook the tediousness of the posting/reposting questions.
By now I am sure you are waving your hands about frantically demanding me to get to the point, well the point is, actually just another same old, same old question...
"How do I code a seemless Java Like RollOver effect, that will not suffer from the disturbingly annoying *flicker or flash*?
I Use VB5 Enterprise Ed. I have 5 images set to "VISIBLE=TRUE" and 5 smaller images that are set to "VISIBLE=FALSE". I use the API and a timer(interval of 1), to track when the user's mouse is placed over the top of a certain image, (obviously a crude explanation of the real coding). This triggers the code to set an appropriate hidden IMAGE to be set to "VISIBLE=TRUE" and the previous image to be set for "VISIBLE=FALSE". This, in theory is supposed to create the Javalike rollover illusion that many of us ar so familiar with. The problem is that the actaul act of hiding/unhiding causes an unnatural anomaly. The images seems to *flicker* quickly before the RollOver effect is complete. I am asking, rather begging for the right person who is skillful and fluent enough with VB5 and RollOver effects, to cure my "Image Flickering" disease.
P.S. Sorry for the repost, but I know that sooner or later the right person will see my post and put an end to my suffering, by injecting me with the appropriate answer.
I appreciate all of your time and efforts spent on the quest at hand, thank you,
Daniel Christie
Please feel free to email me the answer, all though I am sure many of my peers here would love to see the resolve posted on the board..
[Edited by Daniel_Christie on 04-19-2000 at 02:58 AM]
-
Apr 18th, 2000, 03:44 AM
#2
Thread Starter
Addicted Member
Wow, I see the VIEW total but where is all the Replies :-)
I see all the VIEWS for this post but yet there is a lack of Replies. I bet you all are hard at work right now in intense search for the cure.
-
Apr 18th, 2000, 04:06 AM
#3
Addicted Member
I have the answer :)
Ok,
Heres one of two solutions to your horrable
question..
1.If your using a series of picturebox's ,
they WILL flicker no matter what because
they are more then 5k apiece... They take
some time to refresh.
On the other hand a Image is a lot less
advanced but it shouldnt flicker because
the coding for it is alot less space.
Hopefully that was the right answer..
2.The other solution is ActiveX. You can
use a feature of it ( I dont remember
exactly how but I can figure it out
if you must.. )
I hope that helps somewhat..
-
Apr 18th, 2000, 04:15 AM
#4
Thread Starter
Addicted Member
Dayo312,
I thank you for your reply. I will persue the ActiveX. I ofcourse will start out by knowing very little about the subject, yet in time a solid knowledge will ensue.
Dayo312 if you happen to know the solution or it is easily attainable, please by all means enlighten me. :-)
P.S. My images are easily 12k apiece (the size could not be avoided). I have tried both the Image boxes and the Picture boxes. Both produce the same anomaly.
Thanks again,
Daniel Christie
-
Apr 18th, 2000, 05:37 AM
#5
Fanatic Member
Hi daniel,
I was once interested in the coolbar demo at the microsoft site and therefore downloaded it. upon looking at there code i discovered that the switch/rollover was created by detecting when the mouse was over the image, and when it wasn't over it, switch the picture back.
I couldn't help but notice that if i flew the mouse over the image very fast (or reasonably fast - no faster than in normal use - but definately not slow) then it did not detect the movement, the reason for this was that the area directly containing the image was not large enough to detect it when the mouse was moving fast. and having tried a quick sample with activeX controls, have come round to the same conclusion. Another point is that, as these directly containing controls were not large, subsequently the routine to turn the highlight effect off was called whenever the mouse was NOT over the image but was over other controls, ie like the form for example or the toolbar background image too.
Anyway I've emailed you the sample i created, it didnt take long and contains two images, each one is 17Kb and they did not flicker, except when i flew the mouse over the right hand image as the control kinda, was in ready state then rollover state then ready state again (kinda OFF-ON-OFF)
DocZaf
{;->
-
Apr 18th, 2000, 06:51 AM
#6
Thread Starter
Addicted Member
Thanks Zaf Khan
Much appreciated Zaf Khan
I am checking my email right now! :-)
-
Apr 19th, 2000, 02:35 AM
#7
Thread Starter
Addicted Member
Steve's Got Mail!
Thanks _eclipsed_,
I sent Steve an Email. hope he can help. :-)
-
Apr 19th, 2000, 03:44 AM
#8
Fanatic Member
This is in VB6 Pro Ed. It'll probably work on yours
You'll have to account for the SrcInvert when you make your own pictures.
Put three pictures on a form (I don't give a toss about naming conventions). This is my way of telling you how to set the properties more quickly than explaining them to you individually:
Code:
'Picture1 is the Display Picture
With Picture1
.Picture = (None)
End With
'Picture2 is the MouseNotOver Picture
With Picture2
.ScaleMode = 3
.AutoRedraw = True
.Visible = False
.Picture = (Your MouseNotOver Picture)
.BorderStyle = 0
.Appearance = 0
End With
'Picture3 is the MouseOver Picture
With Picture3
.ScaleMode = 3
.AutoRedraw = True
.Visible = False
.Picture = (Your MouseOver Picture)
.BorderStyle = 0
.Appearance = 0
End With
And now for the real code:
Code:
'In Module:
Public PicNorm As Boolean
'In General Declarations:
Private 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
'In Form Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static OpBef
If OpBef = False Then
BitBlt Picture1.hDC, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture2.hDC, 0, 0, vbSrcInvert
OpBef = True
Exit Sub
End If
If PicNorm = False Then
BitBlt Picture1.hDC, 0, 0, Picture3.ScaleWidth, Picture3.ScaleHeight, Picture3.hDC, 0, 0, vbSrcInvert
BitBlt Picture1.hDC, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture2.hDC, 0, 0, vbSrcInvert
PicNorm = True
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If PicNorm = True Then
BitBlt Picture1.hDC, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture2.hDC, 0, 0, vbSrcInvert
BitBlt Picture1.hDC, 0, 0, Picture3.ScaleWidth, Picture3.ScaleHeight, Picture3.hDC, 0, 0, vbSrcInvert
PicNorm = False
End If
End Sub
I don't know if this is what you wanted, but it sure doesn't flicker! (On my computer, anyway)
See ya!
-
Apr 19th, 2000, 03:45 AM
#9
Thread Starter
Addicted Member
Dayo312,
I tried to email ya, but Hotmail replied me back saying that your Juno email address is not a valid user. ????
I am eagerly awaiting your ActiveX solution for my problem with the Java like RollOver code. :-)
-
Apr 19th, 2000, 03:50 AM
#10
Thread Starter
Addicted Member
V(ery) Basic, thanks for your source.
I will try it out as soon as I am home infront of my PC.
Thanks again,
Daniel Christie
-
Apr 19th, 2000, 03:55 AM
#11
Junior Member
Daniel Christie
Daniel I got the same message about that email address. Bet that sucks huh?
-
Apr 19th, 2000, 04:00 AM
#12
Junior Member
I am not sure if this will help you out or not...
Hope you can get something from this to help you out.
Option Explicit
Dim highlighted As Boolean
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
' Highlight the control.
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If highlighted Then Exit Sub
highlighted = True
Label1.ForeColor = vbRed
Timer1.Enabled = True
End Sub
' See if we should unhighlight the control.
Private Sub Timer1_Timer()
Dim pt As POINTAPI
' See where the cursor is.
GetCursorPos pt
' Translate into window coordinates.
ScreenToClient hwnd, pt
' See if we're still within the control.
If pt.x < Label1.Left Or pt.y < Label1.Top Or _
pt.x > Label1.Left + Label1.Width Or _
pt.y > Label1.Top + Label1.Height _
Then
highlighted = False
Label1.ForeColor = vbBlack
Timer1.Enabled = False
End If
End Sub
Let me know if it helped.
-
Apr 19th, 2000, 04:09 AM
#13
Thread Starter
Addicted Member
darkcloud
Your solution is for highlighting text. My issue is concerning large images, I don't think that the two situations can even be compared. I do appreciate your help though. :-)
Thanks,
Daniel Christie
-
Apr 19th, 2000, 04:26 AM
#14
Addicted Member
-
Apr 21st, 2000, 04:17 AM
#15
Thread Starter
Addicted Member
It has been said that I should try to use a offscreen DC.
Can anyone shed some light about how to properly use offscreen DC's?
Thanks all,
Daniel Christie
-
Apr 21st, 2000, 06:21 PM
#16
Fanatic Member
Did it screw up?
Daniel, did my thing not work?
I just want to know what went wrong. If you tell me, maybe
I can revise the code.
Thanks,
Me
-
May 1st, 2000, 08:07 AM
#17
New Member
V(ery)basic,
I tried your code, and it worked with some sample images, but when I tried applying that theory to 10+ images, the rollover one way works, but not when the mouse moves away. Can you post a commented version of the code, so I can figure out what's up?
THanx
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
|