|
-
Feb 12th, 2009, 12:30 AM
#1
Thread Starter
PowerPoster
me.show vs me.visible = true
Have had this in the back of my mind for a while, but am now gonna ask.
Is there any difference at all:
me.show or me.visible = True
me.hide or me.visible = False
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Feb 12th, 2009, 12:34 AM
#2
Re: me.show vs me.visible = true
Yes, there is a difference.
I think .Show calls the ShowWindow() API function but not sure.
But say, if Form2 is minimized, and you set .Visible to false, it will be hidden. If you then set .Visible to True, it will be visible, but still minimized.
But if you just use: Form2.Show, it will restore from taskbar and become visible.
-
Feb 12th, 2009, 12:47 AM
#3
Thread Starter
PowerPoster
Re: me.show vs me.visible = true
 Originally Posted by DigiRev
Yes, there is a difference.
I think .Show calls the ShowWindow() API function but not sure.
But say, if Form2 is minimized, and you set .Visible to false, it will be hidden. If you then set .Visible to True, it will be visible, but still minimized.
But if you just use: Form2.Show, it will restore from taskbar and become visible.
Thanks good to know
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Feb 12th, 2009, 07:15 AM
#4
Re: me.show vs me.visible = true
The big difference, to me, between .Show and .Visible is that .Show is used to load a form that is not currently loaded whereas .Visible makes visible a form that is loaded, but hidden.
BTW: Congrats on 4k DigiRev!
-
Feb 12th, 2009, 07:57 AM
#5
Re: me.show vs me.visible = true
The only difference that I know of...
.Show is a method
.Visible is a property
The Form.Show method is derived from the Control class.
From MSDN: "Showing the control is equivalent to setting the Visible property to true. After the Show method is called, the Visible property returns a value of true until the Hide method is called."
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 12th, 2009, 09:08 AM
#6
Re: me.show vs me.visible = true
Also, don't forget that Show as other optional parameters. Visible does not.
For example. You can show a form and make it modal; you cannot do that with the visible property. Also toggling visible property on a modal form, breaks modality.
-
Apr 21st, 2020, 01:04 PM
#7
New Member
Re: me.show vs me.visible = true
Sorry for ressurecting but
Also toggling visible property on a modal form, breaks modality.
This was the answer i had tried to found many-many days!!! THANK YOU LaVolpe!!!!
-
Apr 21st, 2020, 01:33 PM
#8
New Member
Re: me.show vs me.visible = true
Sorry for ressurecting but
Also toggling visible property on a modal form, breaks modality.
This was the answer i had tried to found many-many days!!! THANK YOU LaVolpe!!!!
-
Apr 21st, 2020, 04:46 PM
#9
Re: me.show vs me.visible = true
Toggling the .Visible property also breaks the form's owner.
So, the only difference I see between .Visible=True and .Show is that .Show allows you to set modality and allows you to set an owner (which is sometimes quite useful).
Now, regarding .Visible=False and .Hide, personally I can't see any difference at all. Both turn off modality and ownership, and both keep the form loaded but hide it. And neither do anything different with the COM instantiation of the form's code.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Apr 22nd, 2020, 09:54 AM
#10
New Member
Re: me.show vs me.visible = true
 Originally Posted by Elroy
Toggling the .Visible property also breaks the form's owner.
So, the only difference I see between .Visible=True and .Show is that .Show allows you to set modality and allows you to set an owner (which is sometimes quite useful).
Now, regarding .Visible=False and .Hide, personally I can't see any difference at all. Both turn off modality and ownership, and both keep the form loaded but hide it. And neither do anything different with the COM instantiation of the form's code.
Yes, you are absolutely right. Be aware that even if the App closes/exit, the hidden form remains in memory and you have to kill the application from task manager or press the stop button from the VB editor.
Thank you a lot
Greetings from Greece!!
-
Apr 22nd, 2020, 10:06 AM
#11
Re: me.show vs me.visible = true
I am doubting this statement:
Be aware that even if the App closes/exit, the hidden form remains in memory and you have to kill the application from task manager or press the stop button from the VB editor.
I would assume if you close all forms in the forms collection, it will go away (hidden or not).
Ex (in main form unload):
Code:
dim f as form
for each f in Forms
unload f
next
-
Apr 22nd, 2020, 10:22 AM
#12
Re: me.show vs me.visible = true
Hi Sam,
gcharal didn't say it well, but I think he just mean, even if you unload all the other forms, that .Visible=False (or frm.Hide) will still have a loaded form which will keep the program from terminating. And then, you've got a program that's running with no visible forms, and that is a Task Manager situation.
More like this... Start a new project, add a Form2, and then put this code in Form1:
Code:
Option Explicit
Private Sub Form_Click()
Form2.Show
Form2.Hide
Unload Me
' After I unload, the app will still be executing but without any visible interface.
End Sub
EDIT: If you're in the IDE, you've still got the IDE's "stop" button. But that's no longer true once compiled.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Apr 22nd, 2020, 10:59 AM
#13
Re: me.show vs me.visible = true
tested:
Code:
Option Explicit
Private Sub Form_Click()
Form2.Show
Form2.Hide
Unload Me
' After I unload, the app will still be executing but without any visible interface.
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim f As Form
For Each f In Forms
Unload f
Next
End Sub
Nothing remains 'running'. So, don't know the problem....
-
Apr 22nd, 2020, 11:02 AM
#14
Re: me.show vs me.visible = true
Hi Sam ... Yes, you added that loop to the Form_Unload which cleaned up the problem. 
EDIT: Also, I always try and run those "Delete" type loops backwards, as I'm never sure what the "Delete" (or, Unload, in this case) is going to do to the collection. It seems to work ok in this case, but, to me, it's more clear if we just run the loop backwards:
Code:
Dim i As Long
For i = Forms.Count - 1& To 0& Step -1&
Unload Forms(i)
Next
Last edited by Elroy; Apr 22nd, 2020 at 11:09 AM.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Apr 22nd, 2020, 11:06 AM
#15
Re: me.show vs me.visible = true
Yeah....so, doesn't EVERYBODY do this???? :-)
-
Apr 22nd, 2020, 11:17 AM
#16
Re: me.show vs me.visible = true
 Originally Posted by SamOscarBrown
Yeah....so, doesn't EVERYBODY do this???? :-)
On a project with less than 10 forms, I don't. Personally, I'd rather see the project hung in the IDE, and then try to figure out what I did to cause that.
Admittedly, on my primary very large project (with 100s of forms), I do have such a loop. However, even there, I'll sometimes comment it out during development to figure something out. But I do leave it in whatever I compile, just in case the user finds some strange-novel way to contort things and leave a form loaded (but not visible) while exiting.
Sam, maybe I'm in a bit of a contrary mood these days, but this seems similar to turning on OERN at the top of every procedure. IDK, it just seems like we should work to make sure our code is doing precisely what we want it to ... and when we want to exit, we haven't forgotten about any hidden forms.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Apr 22nd, 2020, 11:28 AM
#17
Re: me.show vs me.visible = true
That statement by gcharal is true, just not well stated.
If you simply hide a form, and forget to unload it, the project won't terminate because the form is still loaded, running or not. Reworded like that, I don't think there is any debate and is more clear.
In that particular case, app has 2 forms, the main form and some other one that was shown and then hidden, not unloaded. Now the user clicks the X on the main form thinking they terminated the application. Nope, that hidden form is keeping the process alive and needs to be terminated via task manager.
As Sam pointed out there are ways to ensure all forms are unloaded when the main form is closed. But a simple FYI that gcharal threw out there could be helpful for novices.
-
Apr 22nd, 2020, 01:21 PM
#18
New Member
Re: me.show vs me.visible = true
 Originally Posted by SamOscarBrown
I am doubting this statement:
I would assume if you close all forms in the forms collection, it will go away (hidden or not).
Ex (in main form unload):
Code:
dim f as form
for each f in Forms
unload f
next
Yes, i meant without using any other code for closing forms. Like the one you provide, for example...
Bad coding, but i wanted to be clarified.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|