Page 2 of 2

Re: Program start

Posted: Sunday 27th August 2017 7:24pm
by jornmo
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 :)

Re: Program start

Posted: Monday 28th August 2017 10:39am
by cogier
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..

Re: Program start

Posted: Wednesday 30th August 2017 3:02pm
by cogier
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

Re: Program start

Posted: Thursday 31st August 2017 6:56pm
by jornmo
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.

Re: Program start

Posted: Wednesday 6th September 2017 5:02pm
by cogier
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 486 times

Re: Program start

Posted: Friday 8th September 2017 2:23pm
by jornmo
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?

Re: Program start

Posted: Saturday 9th September 2017 1:08pm
by cogier
That's it, you've cracked it! The FMain.Show is the answer. I didn't think of that. Thanks.

Re: Program start

Posted: Monday 11th September 2017 2:12pm
by jornmo
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).

Re: Program start

Posted: Tuesday 12th September 2017 10:10am
by cogier
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

Re: Program start

Posted: Tuesday 12th September 2017 1:33pm
by jornmo
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.