I am having trouble getting a Label control to update the Text string passed to it.
Situation:
I have a DO-LOOP that writes an inquiry file and reads/writes a responce file. During this loop I want the Text in a Label to be changed as the files are read and written.
The problem is the text doesn't get displayed (or rather the control doesn't get refreshed). The loop seems to be running faster than windows can repaint the control. I have tried to put in sleep commands hoping that would pause the program long enough for Windows to repaint the control. But that hasn't helped. Niether has putting in a FF_Control_Redraw call.
Is there a way to force the text in a control to be updated?
Here's the function:
Function GetDrugImageALL () As Long
Local k As Long
Local wk As String
Local wk2 As String
Local w As String
Local t1 As Long
Local t2 As Long
Local rc As Long
Local d As String
Local m1 As String
Local m2 As String
Local m3 As String
rc = MsgBox ("Get Drug Images?" & $CrLf & _
"This may take 5 to 6 hours" _
, %mb_yesno Or %mb_iconquestion Or %mb_taskmodal, "Drug Images")
If rc <> %idyes Then Exit Function
Sleep 1000 ' < -- to allow time enough for messagebox to close
FF_Control_Disable (HWND_FrmMain)
rc = 0
m3 = "Getting Drug Images" & $CrLf & _
"This may take several hours to complete." & $CrLf & _
"Please be patient."
FF_TextBox_SetText (HWND_FormLogon_RICHEDIT1, m3 )
wk = "00000000000~"
Do
' If rc <> 0 Then Exit Do
d = GetNextDgByNDC (wk)
If d = "" Then Exit Do
wk = Parse$(d, Chr$(127), %DgID) ' NDC#
w = Parse$(Parse$(d, Chr$(127), %DgID), "~", 1)
w = Remove$(w , Any "- /")
d = ".\Images\" & Left$(w,9) & ".jpg"
m1 = "Finding- " & d
FF_TextBox_SetText (HWND_FormLogon_Label2, m1)
FF_Control_Redraw(HWND_FormLogon_Label2)
Sleep 2000
If dvFileExist(d) = 0 And Left$(w,5) <> "00990" Then
Kill "XmitDDI.ANS" 'Kill any old stray ANSwer file so we won't pick it up as the answer
Kill "Xmit.DDI" 'Kill any old stray REQuest file
Kill "image.jpg" 'Kill previous image file (if any)
ErrClear
k = FreeFile
wk2 = "xmit.tmp" 'Change extension so it cannot be found until renamed
Open wk2 For Output As #k
Print #k, "J:" + w 'use current 11 digit NDC without dashes
Close #k
ErrClear
Name wk2 As "Xmit.DDI" 'Rename output file to correct name
sleep 1000
t1 = Timer
t2 = t1
'Wait for XmitDDI to return result of inquiry
Do
If Timer - t1 > 2 Then
FF_Control_Redraw(HWND_FormLogon)
t1 = Timer
If dvFileExist("XmitDDI.ANS") = 1 Then t1 = -1 : Exit Do
If t1 - t2 > 30 Then t1 = 0 : Exit Do 'Time out no results
End If
Loop
If t1 = -1 Then
If dvFileExist("image.jpg") = 1 Then
FileCopy "image.jpg", ".\images\" & Left$(w,9) & ".jpg"
m2 = "Last Image- " & Left$(w,9) & ".jpg"
FF_TextBox_SetText (HWND_FormLogon_Label3, m2)
FF_Control_Redraw(HWND_FormLogon_Label3)
End If
'Sleep 1000
Else
m2 = "Skipped- " & d & $CrLf
End If
End If
Loop
FF_Control_Enable (HWND_FrmMain)
? "All Done"
End Function
In VB6, I accomplish this with the DoEvents just after I change the Text or Caption in the controls.
In FF, there is FF_DoEvents in the Functions Library. Looks like something similar.
" Process pending Control or Form messages. Call this function
if you are performing a tight For/Next or Do/Loop and need
to allow your Controls/Forms to be responsive to user input."
Cho, Thank you. Yes, I believe this will do what I want.