Program start

User avatar
jornmo
Site Admin
Posts: 124
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Program start

Post by jornmo » Sunday 27th August 2017 7:24pm

The 'bug' is a big mystery, but this 'solves' the issue:

Remove the FMain's Arrangement from the BuildForm() sub, remove the trigger timer, and replace the BuildPlayArea() sub with this:
Public Sub BuildPlayArea()                                      
  
  hPlayAreaPanel = New Panel(Me)                                 
  With hPlayAreaPanel
    .Arrangement = Arrange.Row                       
    .Expand = True                                    
    .BackGround = Color.Blue
    .W = Me.W - Me.Padding * 2
    .H = Me.H - Me.Padding * 2
  End With
  Me.Arrangement = Arrange.Vertical
  
End
... and voila... don't ask me why :)

User avatar
cogier
Site Admin
Posts: 110
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Program start

Post by cogier » Monday 28th August 2017 10:39am

Thanks Jornmo. That seems to have done the trick. I needed to make a few more alterations but it does not require a trigger any more. I wonder if the Form Arrangement at that late point refreshes the Form?

Update

The display does not regenerate when rebuilt at the end of a game. Looking into it..

User avatar
cogier
Site Admin
Posts: 110
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Program start

Post by cogier » Wednesday 30th August 2017 3:02pm

I was playing with something else and I discovered that the following code will leave the Form_Open() routine without using a Timer.
You can also try Form_GotFocus() instead of Form_Show().
Public Sub Form_Open()

Print "Hello"

End

Public Sub Form_Show()

Print "I got here"

End
Output: -
Hello
I got here

User avatar
jornmo
Site Admin
Posts: 124
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Program start

Post by jornmo » Thursday 31st August 2017 6:56pm

But, its still more of a hack than a proper understanding of the real problem.
I think it has to do with in what order Gambas arranges the controls on the form. It might be that for some reason that is not clear, your subs are called in a different order than expected. You can try using breakpoints to follow (use step/next buttons beside the run button) Gambas' way through the code. You can also enable profiling to see how many times each sub is called.

User avatar
cogier
Site Admin
Posts: 110
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Program start

Post by cogier » Wednesday 06th September 2017 5:02pm

OK I have bumped into this again and my tricks don't work in this case. Have a look at the attached dice simulation. Can it be made to work without the Timer?
GUITest.tar
(287 KiB) Downloaded 7 times

User avatar
jornmo
Site Admin
Posts: 124
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Program start

Post by jornmo » Friday 08th September 2017 2:23pm

For example:
Public Sub Form_Open()
  
  Dim siCount As Short
  
  FMain.Show
  
  For sicount = 1 To 6
    Button1.text = Str(siCount)
    Wait 0.1
  Next
  
  Button1.text = Rand(1, 6)
  
    
End
But, why?

User avatar
cogier
Site Admin
Posts: 110
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Program start

Post by cogier » Saturday 09th September 2017 1:08pm

That's it, you've cracked it! The FMain.Show is the answer. I didn't think of that. Thanks.

User avatar
jornmo
Site Admin
Posts: 124
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Program start

Post by jornmo » Monday 11th September 2017 2:12pm

Still, this hack was not necessary in the example I made for you, so either there's a bug somewhere, or there's something funny in the way you construct your form (that I cannot see).

User avatar
cogier
Site Admin
Posts: 110
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Program start

Post by cogier » Tuesday 12th September 2017 10:10am

I thought you might have a point about the way I put the form together so I tried a new project with code only and it's still the same and wont work without the 'Me.Show' line.
Public Sub Form_Open()
Dim hButton As Button
Dim siCount As Short

With Me
  .Arrangement = Arrange.Vertical
  .padding = 5
  .H = 200
  .W = 200
End With

hButton = New Button(Me)
With hButton
  .expand = True
  .Font.bold = True
  .Font.size = 100
End With

Me.Show

For siCount = 10 DownTo 0
  hButton.Text = Str(siCount)
  Wait 0.2
Next

End

User avatar
jornmo
Site Admin
Posts: 124
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Program start

Post by jornmo » Tuesday 12th September 2017 1:33pm

No, in this example it will not, and that is how it is supposed to be. But, the drawing of you puzzle game form is a bit different from this, and should to my understanding not need a timer, as I have shown with my own code.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest