hide form

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

hide form

Post by gambafeliz »

I want to hide a form. And I have chosen to use these lines of code. Would that be the correct way, thanks.
         ' hide a form
         Me.Opacity = 0
         Me.Minimized = True

         ' show a application
         FMain.Show
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: hide form

Post by BruceSteers »

gambafeliz wrote: Monday 5th September 2022 11:15am I want to hide a form. And I have chosen to use these lines of code. Would that be the correct way, thanks.
         ' hide a form
         Me.Opacity = 0
         Me.Minimized = True

         ' show a application
         FMain.Show
' hide a "Main" form
FMain.Hide
or
FMain.Visible = False

If you need to keep the data in the form alive then set the forms Persistent = True
If the window is not the Application main window then you can just use MyFormName.Close()

If window is not persistent then the fields will need to be filled on each load/open or if it is persistent then the fields will be filled/accessible even when form is hidden/closed
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: hide form

Post by BruceSteers »

Just a note:
How you re-open the window (what your app does while the window is closed) is important to how you can close it.

Ie. if the window is re-opened by using a trayicon click or something then you could just use Me.Close and Me.Show as the application will not quit until you close your trayicon.

You can use Me.Close on the main application window as long as there is something keeping your program alive like a timer event, trayIcon, another open window or an open file handle, etc. (And the forms Persistent property is True)

Hope that makes sense
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: hide form

Post by gambafeliz »

Thanks a lot

But I don't know what happens in my application. "Hide" does not work and "Visible" does not work.

I do not understand why.

I describe what I have done. I had a main window, this has become just a window without more. And I have created a new Form that has taken as main.

And when I hide the main window to "show" the next one, "neither Hide nor Visible" works.

Why? no idea. maybe the order of the final Show?

Note: From my previous post, I have the feeling that my application is contaminated since I changed the main form for another.
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: hide form

Post by BruceSteers »

Without seeing your code it is hard to guess.

The above mentioned code all works as expected for me here so there must be a glitch in your code somewhere keeping the window open or reopening it.

Post your project and we will soon get to the problem :)
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: hide form

Post by BruceSteers »

If the above code is being run from FMain.class then Me and FMain are the same thing.
So this..

' hide a form
Me.Opacity = 0
Me.Minimized = True
 
' show a application
FMain.Show

Just closes and re-opens FMain
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: hide form

Post by BruceSteers »

You should use this order...

Create new form (say it's name is MyForm) in your FMain.class
MyForm = New Form

Initialise new form and open it with
MyForm.Show()
then
FMain.Hide (or Me.Hide if the code is in FMain.class)
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: hide form

Post by gambafeliz »

I clarify
Me = frmSetup (it is Main Form)
FMain = (It is no longer the main one) it is simply a Form that I call from frmSetup
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: hide form

Post by BruceSteers »

Clearly, I cannot guess what is going wrong and i will waste too much time trying to guess.
post your project.

here's something that simply does what you are describing..
Attachments
_aa-0.0.7.tar.gz
(11.96 KiB) Downloaded 82 times
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: hide form

Post by gambafeliz »

thank you Bruce Steers for your kind effort. :)

But although your code is what I am looking for it is impossible for me to implement it in my project.

And I'm sorry to tell you that I don't want to share my project. It is something very personal.

I think for sure. That Gambas3 has messed up and I have broken the project. Because things like "Hide" and other things don't work. In any case, I will continue studying my problem and in the end I will tell you, what happened?

Thank you
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Post Reply