RE: gtk+ in win32



> When I start my program by doubleclicking on the exe-file it 
> does start 
> but it also opens a dos-window. I'vew noticed that xchat in 
> windows does 
> not do this so I guess it's possible to get rid of it. Does 
> anyone know?
> 
> I will have more questions in the future (and already now), what forum
> should I use to ask them?

Well, suppose you have your code already written in Linux and you would like
to run it under Win32 without no mayor changes.  Suppose you already have
your main function defined so you could type something like this:

#ifdef WIN32 

static int 
breakargs(char *program, char *line, char **argv) 
{ 
  int argc = 1; 

  argv[0] = program; 

  while(*line) 
  { while(*line && isspace(*line)) 
      line++; 

    if ( *line == '"' )                 /* Windows-95 quoted arguments */ 
    { char *start = line+1; 
      char *end = start; 

      while( *end && *end != '"' ) 
        end++; 
      if ( *end == '"' ) 
      { *end = '\0'; 
        argv[argc++] = start; 
        line = end+1; 
        continue; 
      } 
    } 

    if ( *line ) 
    { argv[argc++] = line; 
      while(*line && !isspace(*line)) 
        line++; 
      if ( *line ) 
        *line++ = '\0'; 
    } 
  } 
  argv[argc] = NULL; /* add trailing NULL pointer to argv */ 

  return argc; 
} 

int WINAPI 
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int
nShowCmd) 
{ 
  char *argv[100];                                         
  int  argc;                                               
  TCHAR program[MAXPATHLEN];                               

  GetModuleFileName(hInstance, program, sizeof(program));  
  argc = breakargs((char *)program, lpszCmdLine, argv);    
  main(argc, argv); 
  return 0; 
} 

#endif /*WIN32*/ 

Hope it helps,

Esteban Quijano 
Artinsoft corp. 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]