I have a runtime error on Windows if someone double clicks a data file to open it in my app.
The error is in App.OpenDocument.
But how do I catch that in the IDE to debug it???
I can’t think of a way to make double clicking the file launch the IDE version of the app.
My only thought is to add System Debuglog statements through out OpenDocument
to try determine where it is breaking. And then look at that log when the compiled version crashes.
When you open an app by double clicking a data file, does Open get called first and then OpenDocument?
The problem will be that something OpenDocument depends upon hasnt been initialised yet.
If you put Initialisation purely in the App.Open event, sooner or later it will bite you because the events dont always happen in the expected order.
Add a property to the app…
bInitialised as boolean = false
Take the initialisation stuff and put it into an App.Init() method, which also sets
bInitialised = true 'so this only happens once
In App.Open , App.OpenDocument , Activate etc, add code like this as the very first line:
if not App.bInitialised then Call App.Init()
If unsure then it helps to check the documentation:
The application is opening.
The Open event is the first event called when your application starts.
The Activate event is called after the Open event.
@Jeff Tullin should I move everything in Open to Init and not have any code in Open?
Also I have a traditional “splash screen” that opens not on a timer but has buttons for try demo, buy now, or OK if they are activated. After that button I open the main screen that loads the data. Trying to figure out if I when user double clicks file can I still show that but then load the data on the button click. Maybe put the splash screen code in Open, but don’t call Init until after the button is clicked? But will OpenDocument still have the path to the file?
You should use a thread for your splash screen so that the rest of your code can continue.
Its what I did to solve the same problem.
By having a method do all the setting up of memory, dictionaries, classes, whatever, you can call that before you do anything important at startup, and it will only ‘run’ once due to the bInitialised variable.
So it has no effect on startup time.
A Splash screen shouldnt have a ‘do something’ button on it.
As Markus says, display it asynchronously, and have it go away based on a timer or a thread.
Theres nothing wrong with a document opening behind the splash screen -
App.OpenDocument can do its thing, the splash screen can do its own thing.
What you are describing is a Launch screen.
Maybe the App.opendocument can decide if the Splash has been shown already
If yes, open the document.
If no, show the Splash screen without opening the document, but have the opendocument event send the splash screen a value of the ‘file that was doubleclicked’, so that one of your buttons could open it if you want to?