Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Nov 15, 2019 7:50 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: can't close a window
PostPosted: Mon Jan 21, 2013 9:03 am 
Offline

Joined: Fri Dec 09, 2005 6:25 pm
Posts: 357
My app calls an instance of a window (testWindow) with:
dim w as new testWindow(f,t,b)
where it dynamically creates the window to the size of the video so the user can see what they're getting. If they export as a final movie, it flushes the combined movie to a movie file.
If the export is selected, it does not actually need to display the testWindow and I would prefer that it not appear. I tried an if/else statement with testWindow.close, but it complains on Run that the method does not exist. I tried selecting and deselecting ImplicitInstance property with no luck. I also tried calling testWindow.close from within the window's methods and from the menu handler with no luck either. I thought this would be easy to do!


Top
 Profile  
Reply with quote  
 Post subject: Re: can't close a window
PostPosted: Mon Jan 21, 2013 12:11 pm 
Offline

Joined: Mon Aug 14, 2006 9:33 pm
Posts: 1774
Quote:
I also tried calling testWindow.close


It sounds like you are referring to the class (testWindow) rather than the instance (w) of your window. The best way, IMHO, is to have the window close itself (self.close) when it is done or not needed. If that is not possible, dim an instance which will not go out of scope within a single method. i. e. define a property of another window (tWin as new testWindow) and then anywhere within this second window you can call tWin.close.

_________________
Roger Clary
Class One Software
Educational Software for Lifelong Learning
http://www.classonesoftware.com


Top
 Profile  
Reply with quote  
 Post subject: Re: can't close a window
PostPosted: Mon Jan 21, 2013 1:30 pm 
Offline

Joined: Fri Dec 09, 2005 6:25 pm
Posts: 357
it seems to ignore self.close as well (hadn't tried that one), so maybe I'll have to try dimming an instance that will not go out of scope.


Top
 Profile  
Reply with quote  
 Post subject: Re: can't close a window
PostPosted: Mon Jan 21, 2013 5:04 pm 
Offline

Joined: Mon Aug 14, 2006 9:33 pm
Posts: 1774
Quote:
it seems to ignore self.close as well (hadn't tried that one),

You must have a circular reference to that window.

_________________
Roger Clary
Class One Software
Educational Software for Lifelong Learning
http://www.classonesoftware.com


Top
 Profile  
Reply with quote  
 Post subject: Re: can't close a window
PostPosted: Mon Jan 21, 2013 5:34 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
pbesong wrote:
If the export is selected, it does not actually need to display the testWindow and I would prefer that it not appear.

Can you simply not create it in the first place?


Top
 Profile  
Reply with quote  
 Post subject: Re: can't close a window
PostPosted: Mon Jan 21, 2013 6:46 pm 
Offline

Joined: Fri Dec 09, 2005 6:25 pm
Posts: 357
I really don't know what a circular reference is.

The window uses the QTPlugin for RB and the method needs to run to create the movie which is then saved as a new movie. I just wanted to have it close right away after saving.

Also, when the folderitem (f) is saved, i call f.launch but that is ignored too.


Top
 Profile  
Reply with quote  
 Post subject: Re: can't close a window
PostPosted: Mon Jan 21, 2013 7:07 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
a circular reference is where

"A" refers to "B" which in turn refers to "A" which refers to "B" etc....


Circular Reference - See Recursion


Recursion - See Circular Reference

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: can't close a window
PostPosted: Mon Jan 21, 2013 7:10 pm 
Offline

Joined: Mon Aug 14, 2006 9:33 pm
Posts: 1774
Quote:
I really don't know what a circular reference is.

I guessed that you had other code which referred to the window in question and, thus, reopened it.
Obviously, RS programmers close windows and launch folderitems all the time. Without seeing more of your code, I am at a loss for further explanation.

_________________
Roger Clary
Class One Software
Educational Software for Lifelong Learning
http://www.classonesoftware.com


Top
 Profile  
Reply with quote  
 Post subject: Re: can't close a window
PostPosted: Tue Jan 22, 2013 10:00 pm 
Offline

Joined: Fri Dec 09, 2005 6:25 pm
Posts: 357
I finally had a chance to play with this some more and I believe I have what I needed. There were a couple functions in my code that I had to deal with. In the first one, I just added
me.visible = false
and that seemed to make the window disappear (but is it still there in memory?). In the second one I moved
f.launch
down after the call to make the progress bar invisible. Somehow that made it launch the movie in QT Player. Either that or just not having the testWindow open allowed the movie to launch in QT.

Thanks for all the help/suggestions!


Top
 Profile  
Reply with quote  
 Post subject: Re: can't close a window
PostPosted: Wed Jan 23, 2013 10:48 am 
Offline

Joined: Mon Aug 14, 2006 9:33 pm
Posts: 1774
Quote:
I just added
me.visible = false
and that seemed to make the window disappear

Please take these comments in the spirit with which they are offered, We have all been there (and in many cases still are). What you have done is simply put a band aid on your code to make it appear to do what you want. To paraphrase (because I can't remember the exact quote) Steve McConnell, author of Code Complete, "If you don't completely know what your code is doing, it is just a matter of time until it breaks." It is much better to take the time now to refactor your code correctly so that you have a solid base for future updates and your own knowledge.
If you can give us a better outline of what you intend your window, and the code inside, to do, maybe we can make some suggestions.

_________________
Roger Clary
Class One Software
Educational Software for Lifelong Learning
http://www.classonesoftware.com


Top
 Profile  
Reply with quote  
 Post subject: Re: can't close a window
PostPosted: Wed Jan 23, 2013 11:25 am 
Offline

Joined: Fri Dec 09, 2005 6:25 pm
Posts: 357
Yes, while this gets me out of the hot seat, I do intend to explore your suggestions. Without giving all the confusing code, here are the basics of how it works. The user clicks the test button, text and background files are created and passed to the testWindow's constructor method:
app.textFile = txtName
f = getFolderItem(app.filePath+"\"+app.movieName)
t = getFolderItem(app.filePath+"\"+app.textFile)
b = getFolderItem(app.filePath+"\transBkgd.txt")

if f<>nil then
if app.trackPosition = str(val(app.movieHeight)) then
dim w as new testWindow2(f,t,b)
else
dim w as new testWindow(f,t,b)
end if
else
MsgBox "Cannot find the movie."
end if

Constructor marries text and background, then sends it to the mergeMoviesAndPlay method, which creates a canvas the right size for the movie to display in, adds movie controls in the right places and adds the movie to the text/background movie just created:
videoMovie=videoMovie+textMovie
videoDuration = videoMovie.qtDuration
dim p as new QTPlgMovieVideoPlay(videoMovie)
dim list as QTPlgList=p.dataSource.qtTrackListByType(new QTPlgOSType("text"))// we are looking for text tracks only
dim traslateMatrix as QTPlgMatrix
dim list2 as QTPlgList=p.dataSource.qtTrackListByType(new QTPlgOSType("video"))// we are looking for video tracks only
dim traslateVideoMatrix as QTPlgMatrix
dim displayParams as QTPlgCoreDisplayParams
dim bounds as QTPlgRect=p.dataSource.qtBounds

if editorWin.exportQT = true then
if app.trackPosition < app.movieHeight then
traslateMatrix.translate(0,bounds.height-track.qtBounds.height)
else
traslateMatrix.translate(0,bounds.height)
end if

else // if test, do this...

if app.trackPosition < app.movieHeight then
traslateMatrix.translate(0,bounds.height-track.qtBounds.height)
else
traslateMatrix.translate(0,bounds.height)
end if
end if

traslateVideoMatrix = displayParams.matrix
traslateVideoMatrix.translate(0,bounds.height-track.qtBounds.height)

displayParams.matrix=traslateMatrix

track.displayParams=displayParams
next
end if
QTPlgDisplayControl1.width=val(app.movieWidth)

QTPlgDisplayControl1.Height = val(app.movieHeight)


width=QTPlgDisplayControl1.width
height=QTPlgDisplayControl1.height+QTPlgDisplayControl1.top+72
QTPlgDisplayControl1.datasource = p

dim btnLeft as integer
btnLeft = (QTPlgDisplayControl1.width - 210)/2
//center the controls under the movie...
BtnGoStart.left = btnLeft
BtnGoStart.top = QTPlgDisplayControl1.height+27
BtnPrevFrame.left = btnLeft+42
BtnPrevFrame.top = QTPlgDisplayControl1.height+27
BtnPlayStop.left = btnLeft+84
BtnPlayStop.top = QTPlgDisplayControl1.height+27
BtnNextFrame.left = btnLeft+126
BtnNextFrame.top = QTPlgDisplayControl1.height+27
BtnGoEnd.left = btnLeft+168
BtnGoEnd.top = QTPlgDisplayControl1.height+27

Rectangle1.top = QTPlgDisplayControl1.height+12
Rectangle1.width = QTPlgDisplayControl1.width-85
Rectangle1.left = (QTPlgDisplayControl1.width-Rectangle1.width)/2+28

Rectangle2.left = Rectangle1.left
Rectangle2.top = Rectangle1.top
Rectangle2.width = 1

totalSeconds = p.dataSource.timeInfo.lengthInSeconds

if editorWin.exportQT = false then
BtnPlayStop.backdrop=pause
TogglePlay
else
BtnPlayStop.backdrop = play
saveMovieAs
me.visible = false
end if

editorWin.exportQT = false

And if they decide to save the movie they're testing and hit the save button...
dim f as folderitem=GetSaveFolderItem("video/quicktime","untitled.mov")
if f<>nil then
ProgressBar1.Visible=true
QTPlgDisplayControl1.saveAsMovie(f)
ProgressBar1.Visible=false
f.launch
me.visible = false
else
msgBox "Could not save movie."
end if


Top
 Profile  
Reply with quote  
 Post subject: Re: can't close a window
PostPosted: Wed Jan 23, 2013 2:59 pm 
Offline

Joined: Mon Aug 14, 2006 9:33 pm
Posts: 1774
Ah, I think I see. You are doing all of this in the constructor of your recalcitrant window. The window is not really open until the constructor, and super.open(), complete. Since, as best I can tell, you were trying to close this window at the spot where you now have me.visible = false, it was simply reopening itself as the constructor completed.
Why not have a method in a class, or even just another module, do the preparation of your video? Then, when that work is finished, either call the constructor of your window, do the btn placement code, and show the window. If the window is not needed, never call it in the first place.

_________________
Roger Clary
Class One Software
Educational Software for Lifelong Learning
http://www.classonesoftware.com


Top
 Profile  
Reply with quote  
 Post subject: Re: can't close a window
PostPosted: Wed Jan 23, 2013 3:25 pm 
Offline

Joined: Fri Dec 09, 2005 6:25 pm
Posts: 357
That sounds great, but it would probably take someone with my limited skills a while to implement. I got this code as a sample from the plugin I purchased and barely understand what all does what. The documentation for it is over my head basically. hey, i was an art major in college :D


Top
 Profile  
Reply with quote  
 Post subject: Re: can't close a window
PostPosted: Wed Jan 23, 2013 6:09 pm 
Offline

Joined: Mon Aug 14, 2006 9:33 pm
Posts: 1774
I was a music major. ;-)

_________________
Roger Clary
Class One Software
Educational Software for Lifelong Learning
http://www.classonesoftware.com


Top
 Profile  
Reply with quote  
 Post subject: Re: can't close a window
PostPosted: Wed Jan 23, 2013 7:00 pm 
Offline

Joined: Fri Dec 09, 2005 6:25 pm
Posts: 357
that's encouraging! :lol:


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group