Bad screen refresh with sound command

pmu5757

Member
Licensed User
Hello,
When I use the "sound" command in my program, I've got problems with different controls on the form : all controlls should appear before the sound command runs and only some of them do that; the others appear after the sound command ends.

Here is the part of the code concerned.

Could anybody help me ?

Thank You

Pascal - France.

B4X:
Sub App_Start
.......
If CBOptionsVocal.Checked Then
      Sleep (1000)
      Dire (Nb1)
      Select Operation
            Case "+"
                Sound (".\sons\" & CbOptionsLangue.Item(CbOptionsLangue.SelectedIndex) & "_" & "plus.wav")
            Case "-"
                Sound (".\sons\" & CbOptionsLangue.Item(CbOptionsLangue.SelectedIndex) & "_" & "moins.wav")
            Case "x"
                Sound (".\sons\" & CbOptionsLangue.Item(CbOptionsLangue.SelectedIndex) & "_" & "fois.wav")
            Case ":"
                Sound (".\sons\" & CbOptionsLangue.Item(CbOptionsLangue.SelectedIndex) & "_" & "divise.wav")
      End Select
      Sleep (1200)
      Dire (Nb2)
   End If
....
End Sub

Sub Dire (temp)
   Sound (".\sons\" & CbOptionsLangue.Item(CbOptionsLangue.SelectedIndex) & "_" & temp & ".wav")
   Sleep (1200)
End Sub
 

pmu5757

Member
Licensed User
Sorry Agraham, but it doesn't work better...

Here is my new code with your idea...

B4X:
   If CBOptionsVocal.Checked Then
      Sleep (1000)
      Dire (Nb1)
      Select Operation
            Case "+"
            DoEvents 
                Sound (".\sons\" & CbOptionsLangue.Item(CbOptionsLangue.SelectedIndex) & "_" & "plus.wav")
            Case "-"
            DoEvents 
                Sound (".\sons\" & CbOptionsLangue.Item(CbOptionsLangue.SelectedIndex) & "_" & "moins.wav")
            Case "x"
            DoEvents 
                Sound (".\sons\" & CbOptionsLangue.Item(CbOptionsLangue.SelectedIndex) & "_" & "fois.wav")
            Case ":"
            DoEvents 
                Sound (".\sons\" & CbOptionsLangue.Item(CbOptionsLangue.SelectedIndex) & "_" & "divise.wav")
      End Select
      Sleep (1200)
      Dire (Nb2)
   End If
End Sub

Sub Dire (temp)
   DoEvents 
   Sound (".\sons\" & CbOptionsLangue.Item(CbOptionsLangue.SelectedIndex) & "_" & temp & ".wav")
   Sleep (1200)
End Sub
 

agraham

Expert
Licensed User
Longtime User
Sorry Agraham, but it doesn't work better...
Strange! I would have expected that to draw all the outstanding controls. Can you post a bit of code that shows the effect and are we talking about the device or desktop or both? Is this in the IDE and/or compiled with either compiler?
 

Cableguy

Expert
Licensed User
Longtime User
As almost every single command, the DoEvents is very usefull when placed in the correct place...
Here's my altered code, working very fast, and a bit more smooth in the "talking", at least, for my taste...
 

Attachments

  • op.sbp
    10.4 KB · Views: 225

pmu5757

Member
Licensed User
You are wright Cableguy : only one "doevents" is necessary, and before the first "sound" command.
I didn't apply very well Agraham's advice.
It works now.
Thank you both for your help.
 
Top