On Mar 2, 2006, at 1:53 PM, Rubber Chicken Software Co. wrote:
Going further, what if you want to distinguish between whether the
user opens your app directly (by double-clicking the app) and
whether someone drops something on the app to start it?
I want the main Window to appear when the user starts the app, but
when a user drops something on the app, I may want it to process
the file and not open the main Window.
On a drop, the OpenDocument event gets triggered, and starts Open()
before it processes, but then it's a Catch-22, because that's the
only place where the main form can start up automatically.
I am certainly not the most expert RB user reading this list but I
think that I can shed some light on this subject if no one else does so.
Every time your application launches the applications Open event is
fired. Typically this is where I will put the code to load
preferences and initiate any other things that need to be ready
throughout the program.
If the application was launched by double clicking the application
icon then the NewDocument event of the application class will be
invoked and it is here that you would present an open dialog if the
app needs to have a document loaded to work on or present the
starting window. Perhaps you present on open dialog and if a file is
chosen it is used as the file for the opening window and if the user
selects Cancel on the open dialog you present a window for a "New"
whatever it is.
If the user double clicks a file owned by the application or drags a
file owned by the application onto the applications icon then instead
of the NewDocument event firing, the OpenDocument event of the
application class is fired and the folderitem is passed as an
argument to that event. Now you do whatever it is that you need to do
with that file. Open a window and present the contents, whatever.
Note that if the user selects and drags multiple files onto the
application icon, then the OpenDocuemnt event will be called once for
each file. It is up to your code on how you handle this situation,
open a window for each file, or whatever.
If coded properly these two events can also handle Open and New
selections from the File menu.
Giving you an exact example is tough because each app operates
differently but this is the general flow of things everytime your app
is launched. RB knows how it was launched and calls the Open event
followed by either the NewDocuent or OpenDocument events.
As I say, I am certainly not the most knowledgeable RB user on this
list, but this should give you an idea of that initial program
processing. Others may chip in and further clarify things if I have
gotten anything wrong. But this is how I handle things in my apps.
=== A Mac addict in Tennessee ===
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>