views:

609

answers:

3

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??

A: 

You can write a "launcher" program.

The launcher would

  1. Create the splash screen
  2. Launch the matlab exe using CreateProcess() or some other method.
  3. Wait until the matlab exe has opened properly
  4. 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.

Michael J
+1  A: 

With regard to making a splash screen, there are a few submissions on The MathWorks File Exchange that deal with just that:

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.

gnovice
A: 

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.

Andrew Janke