Starting items

Post your Gambas programming questions here.
Post Reply
Online
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Starting items

Post 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.
User avatar
jornmo
Site Admin
Posts: 224
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Starting items

Post 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.
Online
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Starting items

Post 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
didier18
Posts: 38
Joined: Monday 19th December 2016 10:08pm

Re: Starting items

Post by didier18 »

Hello

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

Have a good day
User avatar
jornmo
Site Admin
Posts: 224
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Starting items

Post 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.
User avatar
jornmo
Site Admin
Posts: 224
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Starting items

Post by jornmo »

Btw., '28.wav' is missing :?
Online
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Starting items

Post by cogier »

Well done Didier that did the trick, I used Form_Show()

The missing note has been recaptured!
Online
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Starting items

Post 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
User avatar
jornmo
Site Admin
Posts: 224
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Starting items

Post by jornmo »

Oooohh! I like the colours :lol:
Post Reply