James_stillman
asked on
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.
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.
I want this answer for future referance
ASKER
Cheers for the quick answer Mcrider but I'm still getting the label flicker.
CrazyMan you Tight ******* spend some of your own expert points
CrazyMan you Tight ******* spend some of your own expert points
Freeloading is a time honored profession. :-)
Using the code I gave you, try putting a DoEvents before the line:
LockWindowUpdate 0&
Cheers!
LockWindowUpdate 0&
Cheers!
The more freeloaders the merrier bring em in i say..
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.
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.
James that question you are about to post is not relavent....
And i have no Dandruff okay...
ASKER
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?
https://www.experts-exchange.com/jsp/qShow.jsp?ta=nutrition&qid=10265792
I hope so.
Cheers James
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
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?
https://www.experts-exchange.com/jsp/qShow.jsp?ta=nutrition&qid=10265792
I hope so.
Cheers James
James you are the biggest suck up ive ever seen.
"Thanks McRider"
"I love you McRider"
Bleh!
Do you fancy McRider James?
"Thanks McRider"
"I love you McRider"
Bleh!
Do you fancy McRider James?
Damn Foiled again.
He saw me writing and changed the comments.
Seriously i think he does kind of like you though.
He saw me writing and changed the comments.
Seriously i think he does kind of like you though.
ASKER
CrazyMan. I Don't think crazy is the right word.
Please do not bring your deluded sexual fantasies to my question.
Cheers
James
Please do not bring your deluded sexual fantasies to my question.
Cheers
James
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!
Are you guys in the same office or something??
Cheers!
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
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
Rem Put your delay in here so things don't flow in too fast...
Next intCount
Erf. Make that "I don't know if this will work OR not, but it's easy and it's worth a try!"
Oh, and I guess I didn't use strTyped either. You can remove that. ;-)
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
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
ASKER
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 ;-))))))
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 ;-))))))
McRider,
>>>>Are you guys in the same office or something??
Unfortunatley yes.
:o(
>>>>Are you guys in the same office or something??
Unfortunatley yes.
:o(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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!
Cheers!
ASKER
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
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
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!
By the way, have you thought about mousetraps... 110VAC running through the keyboard could also be interresting... ;-)
Cheers!
If you could get your hands on a sample of the ebola virus... ;-)
Cheers!
Cheers!
ASKER
HHHHmmmmmm............. don't start me thinking.................. ...Could be dangerous.
;^)
;^)
ASKER
Wait he's cxome back to the office get ready for the barrage of lies..
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.
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.
Ive got 4 words for you james that just about sums you up
"The screensaver has failed"
"The screensaver has failed"
>>>>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
Thats an easy one for James ...he just has to touch his genitals
Crazyman, your familiarity with James' genitals concerns me.
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!