Click to See Complete Forum and Search --> : Rollover problems
TGoldfield
Jun 22nd, 2002, 07:43 AM
Ok, it's me again.. (I hear you all sigh)
In my quest to beautify my program I'm replacing the dull grey command buttons with pictures that changes when the mouse is clicked to emulate buttons.
I have tried two methods.. One involves using an image list and swapping the image file over when the button is pressed and the other involves using several pictures and making each visible/invisible when the button is clicked. Both work but both produce a flicker as the button is pressed which, not putting to fine a point on it, looks pretty rubbish!
Is there any way of doing a sort of double buffer or an easier method to prodcue a smooth transition between the frames making them actually look like a buttons.
Cheers, Tim
/\/\isanThr0p
Jun 22nd, 2002, 08:39 AM
well your subject says rollover but in the text it sounds like you only want a up and a down picture. so why not just use buttons? they support this...
and I don't know why both of your methods should flicker... I guess there is just some fault in the code ... post it here or take another look...
TGoldfield
Jun 22nd, 2002, 09:15 AM
I thought about using command buttons but even with the appearance flag set to flat they still seem to have a 3D style border round them. In my design the buttons blend into the background images and often aren't rectangular. I've used pictures because that way I can define what shape they will be because I don't want to actually be able to see the edges of the buttons. Hard to explain!
Anyway, I've checked my code. It's pretty basic stuff but heres the method I'm using now. The buttons are a control array of three pictures and there are 3 image lists, one for each button!
Mousedown:
picMainTab(index).Picture = imlistMainTab(index).ListImages(2).Picture
MouseUp:
picMainTab(index).Picture = imlistMainTab(index).ListImages(1).Picture
See what I mean, Basic.. It still flickers though!
/\/\isanThr0p
Jun 22nd, 2002, 07:54 PM
alright I think the flaw is in the mouse down event
you only need to change the picture if its not already changed...
so check before changing
if not picture = wanted picture than...
get it?
golgo13sf
Jul 4th, 2002, 08:57 PM
i've used this technique and it works without flicker, just preload the images, use an array of images to make life easier
option explicit
'declare picture variables for each buttonstate
dim buttonUp as picture
dim buttonDown as picture
private sub Form_Load()
'set the path to where the images are stored
set buttonUp = loadPicture(app.path & "\images\buttonUp.jpg")
set buttonDown = loadPicture(app.path & "\images\buttonDown.jpg")
end sub
private sub mouseDown( <parameters> )
select case image(index).index
case 0
'button 1 getting pressed
image(0).picture = buttonDown
case 1
case 2...etc
end select
end sub
private sub mouseUp (<parameters>)
select case image(index).index
case 0
'button 1 gets released
image(0).picture = buttonUp
case 1
case 2....etc
end select
end sub
ideally, each button has 3 states, an unpressed, unselected state (ie. button_not_sel), a state where you are pressing the mouse button on it (ie. buttonDown) and a selected state (ie. button_sel), look at any mp3 player to see what i mean
/\/\isanThr0p
Jul 5th, 2002, 01:06 AM
this thread is really old!!!... he never replied...
nevertheless I think it would be enough to check if the pic has already changed... his code is flickering because even if the right picture is there allready the code gets called again and again and reloads his picture every time...
TGoldfield
Jul 5th, 2002, 02:56 AM
Thankyou both for your replies!
I've actually used a method which might be a bit of an overkill but seems to work a treat. I've created a custom control and modified some freeware code I found on the internet written by Gurhan KARTAL.
It uses three bitmaps set up as properties and then uses API calls to draw the appropriate bitmap over the picture box. There are probably simpler methods I could have used but this means that the control can be used like any other command button without too much modification.
Thanks again for your advice!
Tim
csar
Jul 9th, 2002, 12:00 PM
Hi,
I'm very interest your custom command button.
In my design the buttons blend into the background images and often aren't rectangular.
So, how did u check the edge of button (that's not rectangular?) :(
Thank very much
TGoldfield
Jul 10th, 2002, 02:53 AM
I actually had to cheat on that one. I've produced the button graphics in Photoshop and some of them are indeed round. I've produces the custom button such that it has no border, no focus rectangle and as such the edges of the button blend perfectly into the background image. The buttons I've created all have an over, up and down image so when the button is pressed the image changes to simulate it being pushed down. Obviously because there is no image border the round buttons appear as round buttons even though the custom control is actually rectangular.
Obviously you have the issue that you can sometimes press the button if your not exactly over it but within the custom control but that doesn't really bother me too much because my control are all quite small and it's not really noticable. You could modify the code to include some kind of checking for whether the mouse is within the round graphics but I didn't bother because it wasn't nescessary.
Good luck
Tim
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.