Anybody know why a cmd.exe window is used when lyx starts?

OK. Answer my own question:

I have confirmed that if I add the attached wrapper to the main()
function in main.C, and add /subsystem:windows to scons/LINKFLAGS, lyx
would no longer be a console application, and start without the
command window. The wrapper is borrowed from
http://www.flipcode.com/cgi-bin/fcarticles.cgi?show=63933 .

Is there a general interest in this? Lars may not like #ifdef WIN32 in
main.C, some minor (?) autotools adjustment is also needed.

Cheers,
Bo

#include <windows.h>

int main(int argc, char * argv[]);

int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance, char*
command_line, int show_command)
{
   int    argc;
   char** argv;
   char*  arg;
   int    index;
   int    result;
   // count the arguments
   argc = 1;
   arg  = command_line;
   while (arg[0] != 0) {
      while (arg[0] != 0 && arg[0] == ' ') {
           arg++;
       }
      if (arg[0] != 0) {
           argc++;

           while (arg[0] != 0 && arg[0] != ' ') {
               arg++;
          }
       }
  }

 // tokenize the arguments
 argv = (char**)malloc(argc * sizeof(char*));
 arg = command_line;
 index = 1;

 while (arg[0] != 0) {
      while (arg[0] != 0 && arg[0] == ' ') {
         arg++;
     }
     if (arg[0] != 0) {
           argv[index] = arg;
           index++;

           while (arg[0] != 0 && arg[0] != ' ') {
               arg++;
           }

           if (arg[0] != 0) {
               arg[0] = 0;
               arg++;
           }
       }
   }

   // put the program name into argv[0]
   char filename[_MAX_PATH];

   GetModuleFileName(NULL, filename, _MAX_PATH);
   argv[0] = filename;
   // call the user specified main function
   result = main(argc, argv);
   free(argv);
   return result;
}

Reply via email to