Bad screen refresh with sound command

Discussion in 'Questions (Windows Mobile)' started by pmu5757, May 9, 2008.

  1. pmu5757

    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.

    Code:
    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
     
  2. agraham

    agraham Expert Licensed User

    Try a DoEvents just before playing the sound. Hopefully this will let the controls be drawn.
     
  3. pmu5757

    pmu5757 Member Licensed User

    Sorry Agraham, but it doesn't work better...

    Here is my new code with your idea...

    Code:
    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
     
  4. agraham

    agraham Expert Licensed User

    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?
     
  5. pmu5757

    pmu5757 Member Licensed User

    My application is for desktop.
    Here is a version without the "doevent" : http://www.basic4ppc.com/forum/share-your-creations/2141-operations-children.html

    You'll find the whole source code (an old one but still with the problem), and a link to download the whole application (with the sound files)

    Before launching questions in the main form, you must check "vocal" in the options form.

    Thank you.

    Pascal.
     
  6. Cableguy

    Cableguy Expert Licensed 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...
     

    Attached Files:

    • op.sbp
      File size:
      10.4 KB
      Views:
      67
  7. pmu5757

    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.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice