Solved

VB6 pictures flickering when updating such things as shapes/lines/etc

Posted on 2008-10-29
8
518 Views
Last Modified: 2013-12-20
Hello, I have a VB6 form, its basicly a picture control with a shape control as a border.

What it does is loads the picture, and the shape (square) creates a border around the picture. The shape then changes colors, from a light yellow to a dark yellow, kind of like "This image is selected". It uses a timer to change/update the color every 25ms/s.

What seems to be happening is the images themselves seem to be flicking, I don't think the square (the borderline) around the picture is the one flickering, more just the image seems to be.

I needed to know what I can do to solve the flicking of images in VB6, possibly a example, like buffering the image, but I'm not sure how in VB6.

Hopefully it will involve injecting dlls/updating some things rather then removing all the images and starting all over. But eh, got to do what you have to do.

I'll provide the coding on how the image around the borderline is changes, but I'm sure you don't need the coding for loading a image, its simply a loadpicture().

I do know i should combined the timers together, but this was just a quick example on the top of my head. Not a big deal, but you see how the image bordercolor is changing.. That's what I wanted to show..

Suggestions? Thanks!
Private Sub tmrFlashA_Timer()
    If Shape1.BorderColor = &HFFFF& Then
        Shape1.BorderColor = &HEEEE&
    ElseIf Shape1.BorderColor = &HEEEE& Then
        Shape1.BorderColor = &HDDDD&
    ElseIf Shape1.BorderColor = &HDDDD& Then
        Shape1.BorderColor = &HCCCC&
    ElseIf Shape1.BorderColor = &HCCCC& Then
        Shape1.BorderColor = &HBBBB&
    ElseIf Shape1.BorderColor = &HBBBB& Then
        Shape1.BorderColor = &HAAAA&
    ElseIf Shape1.BorderColor = &HAAAA& Then
        Shape1.BorderColor = &H9999&
    ElseIf Shape1.BorderColor = &H9999& Then
        Shape1.BorderColor = &H8888&
    ElseIf Shape1.BorderColor = &H8888& Then
        Shape1.BorderColor = &H7777&
    ElseIf Shape1.BorderColor = &H7777& Then
        Shape1.BorderColor = &H6666&
    ElseIf Shape1.BorderColor = &H6666& Then
        Shape1.BorderColor = &H5555&
        tmrFlashB.Enabled = True
        tmrFlashA.Enabled = False
    ElseIf Shape1.BorderColor = &H5555& Then
        tmrFlashB.Enabled = True
        tmrFlashA.Enabled = False
    End If
End Sub
 
Private Sub tmrFlashB_Timer()
    If Shape1.BorderColor = &H5555& Then
        Shape1.BorderColor = &H6666&
    ElseIf Shape1.BorderColor = &H6666& Then
        Shape1.BorderColor = &H7777&
    ElseIf Shape1.BorderColor = &H7777& Then
        Shape1.BorderColor = &H8888&
    ElseIf Shape1.BorderColor = &H8888& Then
        Shape1.BorderColor = &H9999&
    ElseIf Shape1.BorderColor = &H9999& Then
        Shape1.BorderColor = &HAAAA&
    ElseIf Shape1.BorderColor = &HAAAA& Then
        Shape1.BorderColor = &HBBBB&
    ElseIf Shape1.BorderColor = &HBBBB& Then
        Shape1.BorderColor = &HCCCC&
    ElseIf Shape1.BorderColor = &HCCCC& Then
        Shape1.BorderColor = &HDDDD&
    ElseIf Shape1.BorderColor = &HDDDD& Then
        Shape1.BorderColor = &HEEEE&
    ElseIf Shape1.BorderColor = &HEEEE& Then
        Shape1.BorderColor = &HFFFF&
        tmrFlashB.Enabled = False
        tmrFlashA.Enabled = True
    End If
End Sub
 
Private Sub tmrFlashB_Timer()
    If Shape1.BorderColor = &H5555& Then
        Shape1.BorderColor = &H6666&
    ElseIf Shape1.BorderColor = &H6666& Then
        Shape1.BorderColor = &H7777&
    ElseIf Shape1.BorderColor = &H7777& Then
        Shape1.BorderColor = &H8888&
    ElseIf Shape1.BorderColor = &H8888& Then
        Shape1.BorderColor = &H9999&
    ElseIf Shape1.BorderColor = &H9999& Then
        Shape1.BorderColor = &HAAAA&
    ElseIf Shape1.BorderColor = &HAAAA& Then
        Shape1.BorderColor = &HBBBB&
    ElseIf Shape1.BorderColor = &HBBBB& Then
        Shape1.BorderColor = &HCCCC&
    ElseIf Shape1.BorderColor = &HCCCC& Then
        Shape1.BorderColor = &HDDDD&
    ElseIf Shape1.BorderColor = &HDDDD& Then
        Shape1.BorderColor = &HEEEE&
    ElseIf Shape1.BorderColor = &HEEEE& Then
        Shape1.BorderColor = &HFFFF&
        tmrFlashB.Enabled = False
        tmrFlashA.Enabled = True
    End If
End Sub

Open in new window

0
Comment
Question by:Valleriani
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 22830170
does it help if you set your picture1.autoredraw to false?
0
 
LVL 7

Author Comment

by:Valleriani
ID: 22830237
I realized I was using a "Image" object and not a Picturebox, image seems to appear quicker then pictureboxes, if I use a picturebox and disable autoredraw, the image seems to as well take longer.

The thing is im dealing with many images. Any other ideas?

Thanks and sorry for the miss say, ment Image object.
0
 
LVL 7

Author Comment

by:Valleriani
ID: 22830254
Oh and as well, the flickering was almost solved, but I still saw some flicking if I used a picturebox with autoredraw to off.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Author Comment

by:Valleriani
ID: 22830365
I actually think it may be the shapebox since being under the picturebox that causes it. (minor white appears once and awhile, flicker type.)
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 22830408
have you put the shape inside the picture box or outside?

you can put the shape inside the picturebox
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 22831127
"It uses a timer to change/update the color every 25ms/s."

Good grief...why do you have it flashing so fast?  That would be flashing 40 times a second!

You're going to slam the CPU having multiple timers running that fast...try something larger like 250 ms (4 times a second).

I'm pretty sure the Shape controls are "lightweight" controls which means they do not have their own window handle...so change one would cause the form to refresh and thus all shapes to be repainted.
0
 
LVL 7

Author Comment

by:Valleriani
ID: 22831704
Yeah my bad, forgot to state, but it only does one flash at 25, and only one timer running at a time. But really it does it for 14 frames only once, then it stops unless you select something else. Though raising it to 100-150ms isnt a big deal anyways.

And yeah, thats what I am thinking as well... Is there any other suggestions or controls I can use that would be better for this?
0
 
LVL 7

Author Closing Comment

by:Valleriani
ID: 31511104
If you have any controls that I could possibly use instead of the shape controls, perhaps something that doesn't flicker feel free to post it, otherwise I guess this question is closed.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question