Label Flicker

Ok I don't know if this can be solved but anyway. I have made a kind of Label typewriting function. In that text is printed into a Label one character after another until all of the text has been printed.

The problem is the Label flickers when the text is being written to it an Ideas?

Is there any way of appending text to the label without clearing the Label?
And I don't mean label1.caption = label1.caption & MoreText as this still clears the label out before adding the text.
LVL 1
James_stillmanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mcriderCommented:
Try this... Add the following to the DECLARATIONS SECTION OF THE FORM:

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


Then you can do something like this in your program:

   LockWindowUpdate Form1.hWnd
   Label1.Caption = Label1.Caption + "W"
   LockWindowUpdate 0&


Hope this helps!


Cheers!
0
crazymanCommented:
I want this answer for future referance
0
James_stillmanAuthor Commented:
Cheers for the quick answer Mcrider but I'm still getting the label flicker.

CrazyMan you Tight ******* spend some of your own expert points
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

lmerrellCommented:
Freeloading is a time honored profession.  :-)
0
mcriderCommented:
  Using the code I gave you, try putting a DoEvents before the line:

   LockWindowUpdate 0&


Cheers!
0
crazymanCommented:
The more freeloaders the merrier bring em in i say..
0
mcriderCommented:
By the way, this is the definition of the LockWindowUpdate API:


The LockWindowUpdate function disables or reenables drawing in the specified window. Only one window can be locked at a time.

Parameters
hWndLock
[in] Specifies the window in which drawing will be disabled. If this parameter is NULL, drawing in the locked window is enabled.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero, indicating that an error occurred or another window was already locked.

Windows NT/ 2000: To get extended error information, call GetLastError.

Remarks
If an application with a locked window (or any locked child windows) calls the GetDC, GetDCEx, or BeginPaint function, the called function returns a device context with a visible region that is empty. This will occur until the application unlocks the window by calling LockWindowUpdate, specifying a value of NULL for hWndLock.

If an application attempts to draw within a locked window, the system records the extent of the attempted operation in a bounding rectangle. When the window is unlocked, the system invalidates the area within this bounding rectangle, forcing an eventual WM_PAINT message to be sent to the previously locked window and its child windows. If no drawing has occurred while the window updates were locked, no area is invalidated.

LockWindowUpdate does not make the specified window invisible and does not clear the WS_VISIBLE style bit.

A locked window cannot be moved.

Requirements
  Windows NT/2000: Requires Windows NT 3.1 or later.
  Windows 95/98: Requires Windows 95 or later.
 
0
crazymanCommented:
James that question you are about to post is not relavent....
0
crazymanCommented:
And i have no Dandruff okay...
0
James_stillmanAuthor Commented:
Mcrider - I tried putting the doevents before LockWindowUpdate 0& in the loop and it made the flicker worse. Here is the loop I'm using can you tell me if I am using it right?

Public Declare Function timeGetTime Lib "winmm.dll" () As Long

Public Sub TypeWriter2(labelIn As Object, strin As String, time As Integer)
Dim intCount As Integer
Dim lTime As Long
Dim intcount2 As Integer
intCount = 1

Do
    lTime = timeGetTime
        LockWindowUpdate Savemain.hwnd
        For intcount2 = 1 To labelIn.UBound
            labelIn(intcount2).Caption = labelIn(intcount2).Caption & Mid(strin, intCount, 1)
            If Savemain.blPWCorrect = True Then Exit For
            DoEvents
        Next
        DoEvents
        LockWindowUpdate 0&
        intCount = intCount + 1
        Do
           If Savemain.blPWCorrect = True Then Exit Do
           DoEvents
        Loop While (timeGetTime - lTime) < time
        If Savemain.blPWCorrect = True Then Exit Do
        DoEvents
    Loop While intCount <= Len(strin)
End Sub

Sorry to post code? But it maybe the only way.

cheers

James


CrazyMan You are right freeloaders are welcome unless they have dandruff.

Is
Your
Problem
Sorted
Yet?

http://www.experts-exchange.com/jsp/qShow.jsp?ta=nutrition&qid=10265792 

I hope so.

Cheers James

0
crazymanCommented:
James you are the biggest suck up ive ever seen.


"Thanks McRider"
"I love you McRider"


Bleh!
Do you fancy McRider James?
0
crazymanCommented:
Damn Foiled again.
He saw me writing and changed the comments.
Seriously i think he does kind of like you though.
0
James_stillmanAuthor Commented:
CrazyMan. I Don't think crazy is the right word.

Please do not bring your deluded sexual fantasies to my question.

Cheers

James
0
mcriderCommented:
Assuming that the form that the label is on is called "Savemain" I don't see any problems with your code... In fact when I run it, I don't see any flicker either... With or without the DoEvents...


Are you guys in the same office or something??


Cheers!
0
BarryTiceCommented:
James -- This is a take on how smooth graphics were handled on the Apple ][+, way back when.

To reduce flicker, animation was done using two graphics screens. Redraws were done on the screen that wasn't showing, and then that screen was shown.

Try creating two array labels, directly on top of each other: lblText(0) and lblText(1).

I don't know if this will work at not, but it's easy and it's worth a try!

dim strTextToType as String
dim strTyped as String
dim intCount as Integer
dim intMod as Integer
dim intNotMod as Integer

lblText(1).Visible = False
lblText(0).Visible = True

strTextToType = "Type this message!"

For intCount = 1 to Len(strTextToType)
    intMod = intCount Mod 2
    intNotMod = (intCount + 1) Mod 2
    lblText(intMod).Text = Left(strTextToType, intCount)
    lblText(intMod).Visible = True
    lblText(intNotMod).Visible = False

    Rem Put your delay in here so things don't flow in too fast...

Next intCount






0
BarryTiceCommented:
Erf. Make that "I don't know if this will work OR not, but it's easy and it's worth a try!"
0
BarryTiceCommented:
Oh, and I guess I didn't use strTyped either. You can remove that. ;-)
0
rovermCommented:
No flickering at all:

Dim strOld As String

Private Sub Text1_Change()
Dim strChar As String

    strChar = Right(Text1, Len(Text1) - Len(strOld))
    Label1.Caption = Label1.Caption & strChar
    strOld = Text1
   
End Sub

0
James_stillmanAuthor Commented:
Ok Thanks for all the response guys.

But I Looked at your solutions and still get the flicker.

McRider - I did a little test with yours to see why you got no  flicker and I did. Try making your label bigger and Put quite a bit of text in and the flicker comes now and again.

Same for Yours Barry and roverns wan't exactly what I was looking for.


Thanks again for th response.

Any Other Ideas?

Cheers

James ;-))))))
0
crazymanCommented:
McRider,

>>>>Are you guys in the same office or something??


Unfortunatley yes.
:o(
0
mcriderCommented:
OK, Ask and you shall receive...

Check out this microsoft KB article. It says it's for VB3, the article still pertains to VB5/6.  By the way, system/graphic card speed have ALOT to to with it... I have a 40mhz system with a 16MB graphics card and I don't get flicker... I take the same program to a 200mhz machine with a 1MB video card and I get the flicker...

PRB: How to Prevent Flicker in the Repaint of a Label
http://support.microsoft.com/support/kb/articles/Q112/6/75.asp?LNG=ENG&SA=MSDN 
 

Cheers!

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mcriderCommented:
In my answer, replace: "I have a 40mhz" with "I have a 400mhz". ;-) God, If I had a 40mhz system I think I'd be using it as a paperweight!


Cheers!
0
James_stillmanAuthor Commented:
Cheers Mcrider

I think I am going to have to live with the flicker.
In answer to am I in the same office as crazyman That would be a yes, which is not good as I spend most of my time explaining to him what's wrong with his code or how to solve certain problems, and in return he is a mouthy little **** who is constantly trying to get into my machine and post phoney Q's on ee , email's to anyone in my email account etc.

Crazyman-aka-A Pain In The Arse.


Anyway enough moaning for one day.  

Thanks Again

James
0
mcriderCommented:
Thanks for the points! Glad I could help!

By the way, have you thought about mousetraps... 110VAC running through the keyboard could also be interresting... ;-)


Cheers!
0
mcriderCommented:
If you could get your hands on a sample of the ebola virus... ;-)


Cheers!
0
James_stillmanAuthor Commented:
HHHHmmmmmm............. don't start me thinking.....................Could be dangerous.

;^)
0
James_stillmanAuthor Commented:
Wait he's cxome back to the office get ready for the barrage of lies..
0
crazymanCommented:
James you slimey Git.
You solving my problems....ha thats a good one, took me 20 minutes to explain to you how to use the Iif and you still cant get it.
0
crazymanCommented:
Ive got 4 words for you james that just about sums you up


"The screensaver has failed"


0
crazymanCommented:
>>>>If you could get your hands on a sample of the ebola virus... ;-)


Thats an easy one for James ...he just has to touch his genitals
0
BarryTiceCommented:
Crazyman, your familiarity with James' genitals concerns me.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.