Solved

Flikering problem in labels & Images

Posted on 2003-11-06
11
388 Views
Last Modified: 2013-12-26
Hi experts,
I am making a progress bar OCX with my custome properties and methods and image.

Now everything is done but when I update the value to be displayed it flickers like anything... I have also added a custom image that even a user can provide to display an image of their choice ..

Even that flickers like anything while updating.

I am almost done with my project but unfortunatelly this flickering problem is delaying my delivery.

Thanks for your help.
msali.
0
Comment
Question by:msali
  • 6
  • 4
11 Comments
 
LVL 18

Expert Comment

by:Sethi
ID: 9694307
Use LockWindowUpdate API before and after the processing starts:

Public Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long

Pass the Hwnd of the windows where the processing is going to start just before the code where processing starts like:
LockWindowUpdate Me.Hwnd

Just aftre the last line of code pass 0 as value:
LockWindowUpdate 0
0
 

Author Comment

by:msali
ID: 9699162
Hi,
I have already tried it but when I use this API and test my app my Progress bar does not move till I move my form and then it shows 100% done.  If I use DoEvents with this API the flickering starts again.

If Use this API and put 2 instances of my control on the form.. the whole screen goes buzark and starts acting funny and starts blinking....

0
 
LVL 18

Expert Comment

by:Sethi
ID: 9699194
Check if this progress bar helps you:
http://www.freevbcode.com/ShowCode.Asp?ID=1841
0
 

Author Comment

by:msali
ID: 9706573
Yes I have seen this progress bar.. but please my question is not regarding Progress bar it is about flickering.....

thanks a lot.
0
 
LVL 18

Expert Comment

by:Sethi
ID: 9706657
I am not trying to deviate from topic. I am just trying to help the other way.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:msali
ID: 9776747
Hi,
After waiting for some time and doing my own research I have finally found a solution.

Thanks for your support.

I hope you would not mind if I ask my community support to delete this quesiton.

Waiting for your acknowledgment.

Thanks again.
0
 
LVL 18

Expert Comment

by:Sethi
ID: 9776899
Not at all, if you can share the solution. that would help lot many users who navigate to this thread
0
 

Accepted Solution

by:
msali earned 0 total points
ID: 9784922
Hi,
Well the solution that I used is combination of StrechBlt and BitBlt.

At the time of initialization I place the image that I want to display in the Pbar in iBarSrc Picture Box.

At the same time I strech that image in iBarScale to make it the same heitht and width as my final iBar picture box

Finally when an increment is called by setting the pb.value property of my pb I set the progress bar using bitblt from my iBarScale picture box.


and booooooooom as a result no flickering at all no matter how may doevents you do or how quick your loop is as i am now using the double buffering principal on my control.



Set the Scale Bar:

 RetValue = StretchBlt(iBarScale.hdc, 0, 0, iBarScale.ScaleWidth, iBarScale.ScaleHeight, iBarSrc.hdc, 0, 0, 1, iBarScale.ScaleHeight, vbSrcCopy)


Set the progress Bar
OneUnit = iBar.ScaleWidth / m_Max
RetValue = BitBlt(iBar.hdc, 0, 0, m_Value * OneUnit, iBar.ScaleHeight, iBarScale.hdc, 0, 0, vbSrcCopy)





-------------------------------------------
Sethi,
Thanks a lot for lett me wrap up the question... you are a real sport.

msali.

0
 
LVL 18

Expert Comment

by:Sethi
ID: 9785042
Nice, solution. Thanks for sharing the knowledge.
0
 
LVL 18

Expert Comment

by:Sethi
ID: 9785044
Please post a comment in CS that you intend to get the refund back but the question to be put in PAQ
0
 

Expert Comment

by:YensidMod
ID: 9785098
Question is PAQed and 250 points refunded.

YensidMod
Experts Exchange Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now