New topic: 

Form Question

<http://forums.realsoftware.com/viewtopic.php?t=44004>

         Page 1 of 1
   [ 11 posts ]                 Previous topic | Next topic          Author  
Message        tseyfarth          Post subject: Form QuestionPosted: Mon May 
14, 2012 5:48 pm                         
Joined: Sat Dec 04, 2010 9:14 pm
Posts: 625                Hello all,

The following code does not appear to work properly.  It resolves to True when 
in fact the form in question is not visible and has not been instantiated.

If frmConnections.Visible = True then


Also, this code resolved to False (not Nil).
If frmConnections = Nil then
  Return
End If



Why is this and what is the correct method to program so that in these cases, 
if the form is not visible, or not instantiated, then whatever I 
wanted/expected, will happen?

If frmConnections.Visible = True then
  'Call frmConnections.UpdateGrid
  
  Result = App.SiteList_SiteInfo.GetAll
  frmConnections.grdSiteInfo.DataSource = App.SiteList_SiteInfo.RsSiteList
  frmConnections.grdSiteInfo.ReQuery(frmConnections.grdSiteInfo.Rows,True)
  frmConnections.grdSiteInfo.Refresh
  
End if



Thanks
Tim   
                             Top                simulanics          Post 
subject: Re: Form QuestionPosted: Mon May 14, 2012 6:01 pm                      
   
Joined: Sun Aug 12, 2007 10:10 am
Posts: 594
Location: Boiling Springs, SC                frmConnection is indeed visible 
although it is not shown, unless you have unchecked it's visible property 

To achieve what you are attempting, set frmConnection's visibility to 
unchecked(false)

then when you invoke
frmConnection.show
make sure to include
frmConnection.visible = true

and upon closing it,
frmConnection.hide
frmConnection.visible = false

Try that 

Take a look at the following example to see how the Visibility property 
actually works
http://www.realstudiodevspot.com/demos/ ... bility.rbp      
_________________
Matthew A. Combatti
Real Studio 2011 r4.3
Visit Real Studio Developer's Spot!
Systems:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8 Beta
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS
~All REAL Compatible~  
                             Top                tseyfarth          Post 
subject: Re: Form QuestionPosted: Mon May 14, 2012 6:33 pm                      
   
Joined: Sat Dec 04, 2010 9:14 pm
Posts: 625                But, at the time, frmConnections was never shown.  
The editor itself does not even show it as active.  Another form is, but not 
that one. This is why I question the whole thing.  If in fact it was 
instantiated, then I would understand the property Visible or Not Visible 
working. But when not instantiated, i would expect it to be Nil and/or an 
exception take place.

Tim   
                             Top                timhare          Post subject: 
Re: Form QuestionPosted: Mon May 14, 2012 6:35 pm                         
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 11298
Location: Portland, OR  USA                Sounds like you're running into 
implicit instantiation.  If frmConnections is the name of the window in your 
project, then it is automatically instantiated when you mention it by name.  
Unless you turn off implicit instantiation on the form, in which case you'll 
get a compile error.

By the time you say "if frmConnections" the framework has instantiated it for 
you.  At that point, ".Visible" is evaluated on the freshly created form.

With implicit instantiation, frmConnections can never be nil.  The very act of 
testing it will cause it to be created.

Quote:then when you invoke
frmConnection.show
make sure to include
frmConnection.visible = true

and upon closing it,
frmConnection.hide
frmConnection.visible = false
Ugh.  This code is redundant.  Show causes visible to be true, while Hide does 
the opposite.

My recommendation would be to rename the form in the project, turn off implicit 
instantitation, and create a global property named "frmConnections" of the 
window type (whatever you renamed it to).  That will make the assumptions in 
your code make sense.

Be sure to instantiate the window with New when you need it.   
                             Top                tseyfarth          Post 
subject: Re: Form QuestionPosted: Mon May 14, 2012 6:54 pm                      
   
Joined: Sat Dec 04, 2010 9:14 pm
Posts: 625                Thanks Guys..

@ Tim, I did not want the form to be instantiated at all.  Are you saying that 
all forms are instantiated on application start automatically?

Thanks guys.
Tim   
                             Top                timhare          Post subject: 
Re: Form QuestionPosted: Mon May 14, 2012 7:01 pm                         
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 11298
Location: Portland, OR  USA                Quote: Are you saying that all forms 
are instantiated on application start automatically?
No, but unless you uncheck the implicit instance box, the form is instantiated 
on first reference.   
                             Top                simulanics          Post 
subject: Re: Form QuestionPosted: Mon May 14, 2012 7:03 pm                      
   
Joined: Sun Aug 12, 2007 10:10 am
Posts: 594
Location: Boiling Springs, SC                yes...and visible is a property 
and show is an event...

it is possible for a Window to be visible and not shown
but impossible for a Window to be Shown and not visible..

hope it makes sense..but that's how it works 
gets instantiated on run unless set not to...      
_________________
Matthew A. Combatti
Real Studio 2011 r4.3
Visit Real Studio Developer's Spot!
Systems:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8 Beta
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS
~All REAL Compatible~  
                             Top                tseyfarth          Post 
subject: Re: Form QuestionPosted: Mon May 14, 2012 7:06 pm                      
   
Joined: Sat Dec 04, 2010 9:14 pm
Posts: 625                Yes I see now. I had the property visible set to 
true, which is what I normally want, I see how the app instantiates the form, 
by itself.  If I turn that off, I get all kinds of error.  So will manage it 
differently.

Thanks again for the help!
Tim   
                             Top                simulanics          Post 
subject: Re: Form QuestionPosted: Mon May 14, 2012 7:08 pm                      
   
Joined: Sun Aug 12, 2007 10:10 am
Posts: 594
Location: Boiling Springs, SC                tseyfarth wrote:Yes I see now. I 
had the property visible set to true, which is what I normally want, I see how 
the app instantiates the form, by itself.  If I turn that off, I get all kinds 
of error.  So will manage it differently.

Thanks again for the help!
Tim

If ever you have question...we are always here     
_________________
Matthew A. Combatti
Real Studio 2011 r4.3
Visit Real Studio Developer's Spot!
Systems:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8 Beta
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS
~All REAL Compatible~  
                             Top                DaveS          Post subject: 
Re: Form QuestionPosted: Mon May 14, 2012 8:15 pm                               
  
Joined: Sun Aug 05, 2007 10:46 am
Posts: 3680
Location: San Diego, CA                simulanics wrote:If ever you have 
question...we are always here 

Hey Simulanics....  don't know about you... while I am here a lot, and do try 
to answer as many questions as possible.... I'm not "ALWAYS" here.... a man has 
gotta sleep sometime..... 

But someone will usually respond fairly quickly in most cases     
_________________
Dave Sisemore
MacPro, OSX 10.7.3 RB2011r3
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top                simulanics          Post 
subject: Re: Form QuestionPosted: Mon May 14, 2012 8:44 pm                      
   
Joined: Sun Aug 12, 2007 10:10 am
Posts: 594
Location: Boiling Springs, SC                DaveS wrote:simulanics wrote:If 
ever you have question...we are always here 

Hey Simulanics....  don't know about you... while I am here a lot, and do try 
to answer as many questions as possible.... I'm not "ALWAYS" here.... a man has 
gotta sleep sometime..... 

But someone will usually respond fairly quickly in most cases 

Off-Topic-
Haha  still you are available and that's important and your feedback is always 
helpful  some people have trouble sleeping because of insomnia...I have trouble 
sleeping because I have Internet connection :-p      
_________________
Matthew A. Combatti
Real Studio 2011 r4.3
Visit Real Studio Developer's Spot!
Systems:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8 Beta
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS
~All REAL Compatible~  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 11 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to