Problems with Message and the window that creates it

New to Gambas? Post your questions here. No question is too silly or too simple.
User avatar
gambafeliz
Posts: 139
Joined: Friday 2nd September 2022 7:50pm
Location: I live in the same city as Picasso

Problems with Message and the window that creates it

Post by gambafeliz »

Problems with Message and the window that creates it.

I explain it:

I have an initial Form, it loads (launches) another form in front of it (called F1), Now this F1 form launches a Message with a request for a response. But what happens to me is that the F1 form is hidden and only the Initial Form + the Message remains. I want everything to look like this: Initial form and above it the F1 form and above it the Message. This is possible? Or do I have to create a question and answer system statically in the F1 form and thus have all the control myself.
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Problems with Message and the window that creates it

Post by cogier »

Try putting Me.Show before you open F1 and again before displaying the Message.
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Problems with Message and the window that creates it

Post by BruceSteers »

I assume you are using the message command in the form.open event?

That won't work as the form.must open first.

Best way is to create a timer and start it in the form open event.

Have the timer event use the message command and form.open can continue to work

Private hTimer as Timer
Public sub Form_Open()
hTimer = New Timer As "Ttimer"
hTimer.Delay = 0
hTimer.Start
End

Public Sub Ttimer_Timer()
Last.Stop 
Wait 0.1 ' might not need this line but a Wait can help.
Message.Question("question")
End

If at first you don't succeed , try doing something differently.
BruceS
User avatar
gambafeliz
Posts: 139
Joined: Friday 2nd September 2022 7:50pm
Location: I live in the same city as Picasso

Re: Problems with Message and the window that creates it

Post by gambafeliz »

Thank you both, I greatly appreciate your help.

I don't know if I should apologize or not. Because I think I have explained it very badly. I apologize just in case. Forgiveness.

I am programming in the IDE and I am not explaining something that happens in an executable program.

So situate yourselves, I'm in the IDE and I do F5

1. Load the FMain.
2. The FMain loads a Form called form1
3. The form1 launches Message to ask with two Yes or No buttons

And right there the form1 disappears and only the IDE and Message remain on the screen but the FMain and form1 are lost from the screen

My question:
Is this normal in the programming environment?
Does this also happen to me if I make the program executable without using the IDE?
Should I dialogue with the user with a personal development instead of Message to avoid these little problems?

Thank you and I hope I have explained it better than before.
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Problems with Message and the window that creates it

Post by BruceSteers »

No that's your coding.
Nothing should hide form automatically.

If form hides it's your code.

Post an example program.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
gambafeliz
Posts: 139
Joined: Friday 2nd September 2022 7:50pm
Location: I live in the same city as Picasso

Re: Problems with Message and the window that creates it

Post by gambafeliz »

BruceSteers wrote: Sunday 27th November 2022 11:02am No that's your coding.
Nothing should hide form automatically.

If form hides it's your code.

Post an example program.
As is normal for you, you are right friend BruceSteers

I have tried with ShowModal(), I always use Show() and it has fixed the problem. And also the graphical user interface now seems more solid and serious for the user.

Goodness :)

Hey seriously I wish you a nice day. Thanks.
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Problems with Message and the window that creates it

Post by cogier »

I assume you are using the message command in the form.open event?

That won't work as the form.must open first.

Best way is to create a timer and start it in the form open event.

Have the timer event use the message command and form.open can continue to work
Private hTimer as Timer
Public sub Form_Open()
hTimer = New Timer As "Ttimer"
hTimer.Delay = 0
hTimer.Start
End
 
Public Sub Ttimer_Timer()
  
Last.Stop 
Wait 0.1 ' might not need this line but a Wait can help.
Message.Question("question")
End
You could simplify this a little using the Trigger command: -

Public Sub Form_Open()

  Dim hTimer As Timer

  hTimer = New Timer As "Timer1"
  hTimer.Trigger

End

Public Sub Timer1_Timer()

  Message.Question("question")

End
User avatar
gambafeliz
Posts: 139
Joined: Friday 2nd September 2022 7:50pm
Location: I live in the same city as Picasso

Re: Problems with Message and the window that creates it

Post by gambafeliz »

Thank you very much cogier
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
User avatar
gambafeliz
Posts: 139
Joined: Friday 2nd September 2022 7:50pm
Location: I live in the same city as Picasso

Re: Problems with Message and the window that creates it

Post by gambafeliz »

Hello, as I have already said, I have solved it with ShowModal, but is it possible to make the form open or change it to Modal or non-Modal on the fly? It would solve a big problem that I have. Thanks.
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
User avatar
thatbruce
Posts: 161
Joined: Saturday 4th September 2021 11:29pm

Re: Problems with Message and the window that creates it

Post by thatbruce »

gambafeliz wrote: Wednesday 30th November 2022 6:07am but is it possible to make the form open or change it to Modal or non-Modal on the fly?
Not in this universe.
There are many things you can't change "on the fly" when using a GUI, the basic reason is that once the Gambas executable is "started" from your codes perspective it has already committed to a life long "partnership". Thus, you can't change the GUI, it's handlers, and many other things. But for future references you may care to look at the "Utility" property of your forms. (Actually, I'll be damned if I can work out what it does exactly, but it has caught me out more times than I care to admit.)
hth
b
Have you ever noticed that software is never advertised using the adjective "spreadable".
Post Reply