Label Caption Doesn't Change When Changed 
Author Message
 Label Caption Doesn't Change When Changed

Hi,
   I have a label that is on a form that is updated from code not on the
form.  Below is a few lines of code.  This is for a progress meter.

   For Count = 1 To LCount
      frmProgressBar.lblCount.Caption = Format(Count, "##0")
      DoEvents
      frmProgressBar.prbBar.Value = Count
      Map = frmUpdate.lstSendMaps.List(Count - 1)
      For count2 = 1 To upbound 'Search MapInfo() for it

When stepping through the code the line frmProgressBar.lblCount.Caption =
Format(Count, "##0") actually works and I see the caption changed to the
next number.  When running the code without stepping, the number in the
label never changes from its first value.  I couldn't see the numbers change
in the caption until I added "DoEvents".  What follows in the second loop is
copying of many files 187k in size.  I'm guessing that throwing DoEvents in
there is "pausing" execution so that the caption is updated (among other
things).  How come I have to throw that in to see the label caption update?
Oddly enough, the "chunks" in the progress meter control never had problems
displaying while the caption did.
   I had to do the same thing when I wanted to show this form.  Otherwise it
barely drew 10% of itself on the screen.

Thanks,
Bill



Thu, 05 Oct 2000 03:00:00 GMT  
 Label Caption Doesn't Change When Changed

Bill,
The way windows works in terms of refreshing & DoEvents is the cause/source
of the behavior you are seeing. The DoEvents call will cause windows to
execute pending events for ALL windows, such as updating the label caption
in your app.
If you want to remove the DoEvents, you can insert an API call instead:
Refer to the API Text Viewer (it comes with VB) for the definition of the
call 'UpdateWindow'. This API can update just the control(s) you want, such
as the label. Call it like this:
Call UpdateWindow(frmProgrssBar.lblCount.hWnd)
in place of the DoEvents line.
In the case of a loop like yours, control will not be returned to Windows
for it to update other objects. This behavior is also apparent in database
interaction when the query is long-running, or executing synchronously over
a network.

Quote:

>Hi,
>   I have a label that is on a form that is updated from code not on the
>form.  Below is a few lines of code.  This is for a progress meter.

>   For Count = 1 To LCount
>      frmProgressBar.lblCount.Caption = Format(Count, "##0")
>      DoEvents
>      frmProgressBar.prbBar.Value = Count
>      Map = frmUpdate.lstSendMaps.List(Count - 1)
>      For count2 = 1 To upbound 'Search MapInfo() for it

>When stepping through the code the line frmProgressBar.lblCount.Caption =
>Format(Count, "##0") actually works and I see the caption changed to the
>next number.  When running the code without stepping, the number in the
>label never changes from its first value.  I couldn't see the numbers
change
>in the caption until I added "DoEvents".  What follows in the second loop
is
>copying of many files 187k in size.  I'm guessing that throwing DoEvents in
>there is "pausing" execution so that the caption is updated (among other
>things).  How come I have to throw that in to see the label caption update?
>Oddly enough, the "chunks" in the progress meter control never had problems
>displaying while the caption did.
>   I had to do the same thing when I wanted to show this form.  Otherwise
it
>barely drew 10% of itself on the screen.

>Thanks,
>Bill



Thu, 05 Oct 2000 03:00:00 GMT  
 Label Caption Doesn't Change When Changed


schreibt:

Quote:
>      frmProgressBar.lblCount.Caption = Format(Count, "##0")
>      DoEvents

If DoEvents doesn't help, use lblCount.Refresh or frmProgressBar.Refresh. This
should always update the control.

DoDi



Fri, 06 Oct 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Change label caption in userform on change of dropdown listbox

2. Permanently change a text label's caption?

3. Changing control name of button doesn't change event name to be the same

4. Auto label/Caption change

5. Changing the caption property on a label at run time

6. Label Caption Change

7. Changing label captions: how to refresh

8. Change caption of a label in DataReport at runtime

9. Changing Label Captions on a Data Report.

10. Changing a Label caption

11. Changing label captions while running code

12. Change label.caption from a DLL.

 

 
Powered by phpBB® Forum Software