Hello!
Why does vb control flashes when their property value is changed very fast, let's say like this:
for i=1 to 2500
label1.width=i
label1.refresh
next
Printable View
Hello!
Why does vb control flashes when their property value is changed very fast, let's say like this:
for i=1 to 2500
label1.width=i
label1.refresh
next
It's the updating speed of your Monitor.
Huh...
And what can I do against that?
You can try 1 of 2 things. First, try removing the Label1.Refresh line. It will not blink as much.
If that does not satisfy you, then you can use the LockWindowUpdate API.Make sure you enclose your Label in a container (like the PictureBox) because we'll lock that instead of the Form. If we lock the Form, then it will freeze.
Make a Form with a PictureBox, CommandButton and a Label. Place the Label inside the PictureBox and insert the following code into the Form.
Code:Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Private Sub Command1_Click()
LockWindowUpdate Picture1.hWnd
For i = 1 To 2500
Label1.Width = i
Label1.Refresh
Next
End Sub
And if I do that, the label1 will still be refreshed without flashing?
Let me explain what am I doing. I have 2 labels. In first is static text and in second which is dynamicly resizing is the same text, just colored with some other color. The point of my program is to resize the label at specific milisecond to specific width to color text for singing (kind a caraoke thing).
It's complicated explained, but I hope you'll understand.
Or is there any other way to do it?
LockWindowUpdate will not work in your case then. Try removing the Label1.Refresh line.
Code:For I = 1 to 2500
Label1.Width = I
Next I