Results 1 to 6 of 6

Thread: Flashing in VB

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ilirska Bistrica, Slovenia
    Posts
    242

    Question

    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
    Zvonko Bostjancic
    Ilirska Bistrica, Slovenia
    [email protected]
    Using VS6 Professional with SP3
    Programming mostly in VB and I've started to learn VC++ & MFC

  2. #2
    Guest
    It's the updating speed of your Monitor.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ilirska Bistrica, Slovenia
    Posts
    242
    Huh...
    And what can I do against that?
    Zvonko Bostjancic
    Ilirska Bistrica, Slovenia
    [email protected]
    Using VS6 Professional with SP3
    Programming mostly in VB and I've started to learn VC++ & MFC

  4. #4
    Guest
    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

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ilirska Bistrica, Slovenia
    Posts
    242
    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?
    Zvonko Bostjancic
    Ilirska Bistrica, Slovenia
    [email protected]
    Using VS6 Professional with SP3
    Programming mostly in VB and I've started to learn VC++ & MFC

  6. #6
    Guest
    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

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