New topic: 

trying to close a window created with new

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

         Page 1 of 1
   [ 5 posts ]                 Previous topic | Next topic          Author  
Message        brianheibert          Post subject: trying to close a window 
created with newPosted: Wed Jun 09, 2010 7:03 pm                                
 
Joined: Sat Jan 23, 2010 3:03 pm
Posts: 214
Location: Loveland,OH 45140                I have two menuitems in my file menu 
File->New
File->Close

I got file new working using
dim w as new mainwindow
w = new mainwindow

I am getting a nilobject exception using w.close 
to try to close the window when the user selects File->Close

dim w as mainwindow
w.close
  
What am I doing wrong?

Brian   
                             Top                 markwalsh          Post 
subject: Re: trying to close a window created with newPosted: Wed Jun 09, 2010 
7:13 pm                         
Joined: Wed May 20, 2009 4:43 pm
Posts: 147                brianheibert wrote:I have two menuitems in my file 
menu 
File->New
File->Close

I got file new working using
dim w as new mainwindow
w = new mainwindow

I am getting a nilobject exception using w.close 
to try to close the window when the user selects File->Close

dim w as mainwindow
w.close
  
What am I doing wrong?

Brian
What is the scope of 'w'? Are you calling w.close in the same method as it is 
initialized? If it's in a different method, you don't declare it in the method 
where you are closing it.      
_________________
RB 2009r4 Windows XP  
                             Top                 brianheibert          Post 
subject: Re: trying to close a window created with newPosted: Wed Jun 09, 2010 
7:28 pm                                 
Joined: Sat Jan 23, 2010 3:03 pm
Posts: 214
Location: Loveland,OH 45140                ok so it's not in the window or 
other parts of the program
it is in the File Close menu handler

So if it is in the wrong place where do I put it 
and how do I get my File Close menu to access it?

Brian   
                             Top                 markwalsh          Post 
subject: Re: trying to close a window created with newPosted: Wed Jun 09, 2010 
7:37 pm                         
Joined: Wed May 20, 2009 4:43 pm
Posts: 147                brianheibert wrote:ok so it's not in the window or 
other parts of the program
it is in the File Close menu handler

So if it is in the wrong place where do I put it 
and how do I get my File Close menu to access it?

Brian
'w' should be a property that is available to both methods where you want to 
create/close it. If you're calling it in a window, then remove:
Code:dim w as new mainwindow
and make 'w' a property of that window.      
_________________
RB 2009r4 Windows XP  
                             Top                 serd83          Post subject: 
Re: trying to close a window created with newPosted: Wed Jun 09, 2010 7:54 pm   
                      
Joined: Thu Feb 22, 2007 7:08 pm
Posts: 1133                As markwalsh said, make it a global property, but 
use better a more meaningful name for it. For example name it ToolWindow(just 
for example), instead just W. When you use
Code:dim w as new mainwindow
You declare a local variable. 
When you use this to close the Window you create like above:
Code:dim w as mainwindow
w.close
The Menu or other Events know nothing about the variable(Window) W. Make it a 
global property
Code:toolwindow as window
To create it:
Code:toolwindow = new mainwindow // don't use dim toolwindow as...
To close:
Code:toolwindow.Close
Dim is also only there available where you use it. In the LR, under "Dim", this 
is good described.   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 5 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