Results 1 to 9 of 9

Thread: Rollover problems

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Posts
    16

    Rollover problems

    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

  2. #2
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    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...
    Sanity is a full time job

    Puh das war harter Stoff!

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Posts
    16
    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!

  4. #4
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    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?
    Sanity is a full time job

    Puh das war harter Stoff!

  5. #5
    Lively Member
    Join Date
    Mar 2002
    Posts
    110
    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

  6. #6
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    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...
    Sanity is a full time job

    Puh das war harter Stoff!

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Posts
    16
    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

  8. #8
    Hyperactive Member csar's Avatar
    Join Date
    Mar 2002
    Location
    Siam
    Posts
    288

    and how to check the edge!

    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
    Don't leave it till tomorrow, Do It Now!
    5361726176757468204368616E63686F747361746869656E

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Posts
    16
    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

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