Form timer puzzle

M

Michael

I have a form with several command buttons. One of them invokes the
following procedure.
On the form is a 'progress messae' called txtBuildBitmapsProgress.

What I want is for the message to blink.

When the procedure is executed the first message appears but does not blink.
After intervening processing the second message appears but does not blink.
After more processing the third message appears and it does blink.

I cannot understand the logic of why the messages do not blink from the
beginning.

(Other command buttons set the TimerInterval to 0 to stop the blinking ok.)

Any help would be appreciated.

All the best,

Michael.

------------------------------------------------------------------

Private Sub cmdBuildBmps_Click()
....
Me.TimerInterval = 500
Me.txtBuildBitmapsProgress = "Building Item Descriptions"
Me.Repaint
....
Me.txtBuildBitmapsProgress = "Building Bitmaps"
Me.Repaint
....
Me.txtBuildBitmapsProgress = "Complete"
Me.Repaint
End Sub

------------------------------------------------------------------
Private Sub Form_Timer()

Static blnBlink As Boolean

If blnBlink Then
' Show field
Me.txtBuildBitmapsProgress.Visible = True
Else
' Don't show field
Me.txtBuildBitmapsProgress.Visible = False
End If

blnBlink = Not blnBlink

End Sub
 
M

Marshall Barton

The issue here is one of process and task priorities, not
one of your code logic. VBA code processing runs as a high
priority task where repainting the screen is a low priority
task. In other words, Repaint never gets a chance to do its
thing because your code or other windows activities are
keeping your system fully occupied.

Sometimes(??), you can jiggle this can of worms by using
DoEvents instead of Repaint. This is preferred because
repainting the entire form is a time comsuming task.

Sometimes(??), you might have to use one or two DoEvents
after the Repaint.

Othertimes (it may(?) depend on what else Windows is doing),
nothing can make it do what you want. All in all, it's a
rather iffy thing without taking control of your entire
system (like many games do).

Bottom line, if either of the DoEvents ideas don't take care
of it, you should find some other way to indicate progress.
Maybe using Beep at strategic paces in the bitmap
procedures.
 
M

Michael

Hi Marshall,

Thanks for this - I am not mad after all.

M.

Marshall Barton said:
The issue here is one of process and task priorities, not
one of your code logic. VBA code processing runs as a high
priority task where repainting the screen is a low priority
task. In other words, Repaint never gets a chance to do its
thing because your code or other windows activities are
keeping your system fully occupied.

Sometimes(??), you can jiggle this can of worms by using
DoEvents instead of Repaint. This is preferred because
repainting the entire form is a time comsuming task.

Sometimes(??), you might have to use one or two DoEvents
after the Repaint.

Othertimes (it may(?) depend on what else Windows is doing),
nothing can make it do what you want. All in all, it's a
rather iffy thing without taking control of your entire
system (like many games do).

Bottom line, if either of the DoEvents ideas don't take care
of it, you should find some other way to indicate progress.
Maybe using Beep at strategic paces in the bitmap
procedures.
--
Marsh
MVP [MS Access]

I have a form with several command buttons. One of them invokes the
following procedure.
On the form is a 'progress messae' called txtBuildBitmapsProgress.

What I want is for the message to blink.

When the procedure is executed the first message appears but does not
blink.
After intervening processing the second message appears but does not
blink.
After more processing the third message appears and it does blink.

I cannot understand the logic of why the messages do not blink from the
beginning.

(Other command buttons set the TimerInterval to 0 to stop the blinking
ok.)
------------------------------------------------------------------

Private Sub cmdBuildBmps_Click()
...
Me.TimerInterval = 500
Me.txtBuildBitmapsProgress = "Building Item Descriptions"
Me.Repaint
...
Me.txtBuildBitmapsProgress = "Building Bitmaps"
Me.Repaint
...
Me.txtBuildBitmapsProgress = "Complete"
Me.Repaint
End Sub

------------------------------------------------------------------
Private Sub Form_Timer()

Static blnBlink As Boolean

If blnBlink Then
' Show field
Me.txtBuildBitmapsProgress.Visible = True
Else
' Don't show field
Me.txtBuildBitmapsProgress.Visible = False
End If

blnBlink = Not blnBlink

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top