Ive used the Matlab Compiler to create a .exe file.. The program takes 15 sec to start.. So I figured that I needed to get rid of the DOS window and needed a splash screen.. How can I do that??
You can write a "launcher" program.
The launcher would
- Create the splash screen
- Launch the matlab exe using CreateProcess() or some other method.
- Wait until the matlab exe has opened properly
- Exit
The tricky bit will be determining when the matlab program has started. One method might be to call EnumWindows() and GetWindowText() in a loop, looking for the matlab window title, but you might be able to come up with a better way given knowledge of what the matlab program does.
You would probably need to keep checking that the matlab process hasn't died, in case something goes wrong.
With regard to making a splash screen, there are a few submissions on The MathWorks File Exchange that deal with just that:
- Fancy splash screen for compiled .exe GUIs from W Thielicke
- splash.m from Qun Han.
- Splash Screen from Roy Schestowitz.
I haven't used any of them personally, but they should at the very least give you some guidance if you want to design your own splash screen functionality.
To get rid of the DOS window, use "mcc -e" instead of "mcc -m". See "MATLAB Compiler > Function Reference" in the online documentation, brought up by doc(). You might not want to do that, though: the DOS window is the output of last resort; it's where unhandled exceptions, core dumps, and other diagnostic output go. At least make it an option so you can have a debug build that has the DOS window.
In my experience, the startup overhead for a compiled standalone Matlab program happens before control transfers to user M-code, so a splash screen will need to be done in an external program, or hooked in to the C wrapper that mcc generates. You could use Michael J's suggestion of writing a launcher. You're not looking for matlab.exe or a Matlab desktop window, though, since this is a standalone app. To detect when the matlab program has started, have your M-code write out a little temp file as the first thing the program does, and have your launcher watch for that.