Page 1 of 1

Starting items

Posted: Thursday 9th March 2017 4:56pm
by cogier
Is there a way to get something to start AFTER the Form has been displayed other than using a Timer.

Example: - I want to display a Form then play a tune. If I put it in Public Sub Form_Open() it will not show the Form until the tune has played.

Re: Starting items

Posted: Thursday 9th March 2017 7:43pm
by jornmo
Try adding Wait before the play.
If Delay is not specified, the function processes all pending events and returns immediately. In that specific case, input events (keyboard and mouse) are ignored.

Re: Starting items

Posted: Thursday 9th March 2017 10:01pm
by cogier
Ahh. So simple, why didn't I think of that? BUT it doesn't work!!

The attached uses a Timer to get the result I am looking for. Simply change 'bWait As Boolean = True' to
'bWait As Boolean = False' to see that it doesn't react as expected.

Please note the software is in the VERY early stages of development..
piano.tar
(7.47 MiB) Downloaded 467 times

Re: Starting items

Posted: Thursday 9th March 2017 11:18pm
by didier18
Hello

Can be put the code in:
Public Sub Form_Arrange ()
or in :
Public Sub Form_Show ()

Have a good day

Re: Starting items

Posted: Friday 10th March 2017 2:06pm
by jornmo
I've tried did's solution.

This works:

Code: Select all

Public Sub Form_Show()
  
  playStuff("4C2,3C2,2C2,1E2,1D2,1C8,\n")                       'Send Intro string of notes to playStuff
  
End
However, the Arrange event is not good for this.

Re: Starting items

Posted: Friday 10th March 2017 2:09pm
by jornmo
Btw., '28.wav' is missing :?

Re: Starting items

Posted: Friday 10th March 2017 4:45pm
by cogier
Well done Didier that did the trick, I used Form_Show()

The missing note has been recaptured!

Re: Starting items

Posted: Sunday 12th March 2017 4:11pm
by cogier
UPDATE:

Form_Show() only shows the form immediately with gb.gui
Form_Arrange() does not show the form until the the routine has finished
Form_Open() does not show the form until the the routine has finished
Form_Active() shows the form immediately with gb.gui and gb.qt4

You need one Label on a form for this to work

Public Sub Form_Activate()
Dim siCount As Short
Dim siNotes As Short[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]

For siCount = 0 To siNotes.Max
  Label1.text &= siNotes[siCount] & " "
  Wait 0.25
Next

Re: Starting items

Posted: Sunday 12th March 2017 4:14pm
by jornmo
Oooohh! I like the colours :lol: