Hi,

Ok, here is attempt #1.  Recent versions of NT have an API to find the 
console window handle removing any pause.  For older versions of Windows 
it still does the set console title hack but now will pause up to .2s in 
case the system is busy when doing it.  It also always breaks the link 
to the console if it was made in the first place.

It should compile and work with Borland compiler but I cannot test that, 
sorry.

TTFN

Mike
-- 
If you have a difficult task, give it to a lazy person... they will find 
an easier way to do it.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

*** if_cscope.c.orig    Sat May 12 14:03:00 2007
--- if_cscope.c Tue Aug 07 22:46:55 2007
***************
*** 712,717 ****
--- 712,723 ----
  } /* cs_create_cmd */
  
  
+ #ifdef __BORLANDC__
+ typedef HWND (__stdcall *GETCONSOLEWINDOWPROC)(VOID);
+ #else
+ typedef WINBASEAPI HWND (WINAPI *GETCONSOLEWINDOWPROC)(VOID);
+ #endif
+ 
  /*
   * PRIVATE: cs_create_connection
   *
***************
*** 728,733 ****
--- 734,740 ----
      int in_save, out_save, err_save;
      long_i ph;
  # ifdef FEAT_GUI
+     int console_open;
      HWND activewnd = NULL;
      HWND consolewnd = NULL;
  # endif
***************
*** 860,885 ****
  # ifdef FEAT_GUI
        activewnd = GetForegroundWindow(); /* on win9x cscope steals focus */
        /* Dirty hack to hide annoying console window */
!       if (AllocConsole())
        {
!           char *title;
!           title = (char *)alloc(1024);
!           if (title == NULL)
!               FreeConsole();
!           else
!           {
!               GetConsoleTitle(title, 1024); /* save for future restore */
!               SetConsoleTitle(
!                   "GVIMCS{5499421B-CBEF-45b0-85EF-38167FDEA5C5}GVIMCS");
!               Sleep(40); /* as stated in MS KB we must wait 40 ms */
!               consolewnd = FindWindow(NULL,
                        "GVIMCS{5499421B-CBEF-45b0-85EF-38167FDEA5C5}GVIMCS");
!               if (consolewnd != NULL)
!                   ShowWindow(consolewnd, SW_HIDE);
!               SetConsoleTitle(title);
!               vim_free(title);
!           }
!       }
  # endif
        /* May be use &shell, &shellquote etc */
  # ifdef __BORLANDC__
--- 867,909 ----
  # ifdef FEAT_GUI
        activewnd = GetForegroundWindow(); /* on win9x cscope steals focus */
        /* Dirty hack to hide annoying console window */
!       if (console_open = AllocConsole())
        {
!             /* From Win2K can use Win32 API to get the console window handle 
*/
!             GETCONSOLEWINDOWPROC GetConsoleWindowProc;
!             if ((GetConsoleWindowProc = (GETCONSOLEWINDOWPROC)
!                     GetProcAddress(GetModuleHandle("KERNEL32.DLL"),
!                             "GetConsoleWindow")) != NULL) {
!                 consolewnd = (*GetConsoleWindowProc)();
!                 if (consolewnd != NULL)
!                     ShowWindow(consolewnd, SW_HIDE);
!             }
!             else
!             {
!                 char *title;
!                 title = (char *)alloc(1024);
!                 if (title == NULL)
!                     FreeConsole();
!                 else
!                 {
!                     int count;
!                     GetConsoleTitle(title, 1024); /* save for future restore 
*/
!                     SetConsoleTitle(
!                         "GVIMCS{5499421B-CBEF-45b0-85EF-38167FDEA5C5}GVIMCS");
!                     /* 40ms usually is long enough, but if the system is busy
!                      * allow a bit longer */
!                     do {
!                         Sleep(40);
!                     consolewnd = FindWindow(NULL,
                        "GVIMCS{5499421B-CBEF-45b0-85EF-38167FDEA5C5}GVIMCS");
!                     } while (consolewnd == NULL && ++count <= 5);
!                     if (consolewnd != NULL)
!                         ShowWindow(consolewnd, SW_HIDE);
!                     SetConsoleTitle(title);
!                     vim_free(title);
!                 }
!             }
!         }
  # endif
        /* May be use &shell, &shellquote etc */
  # ifdef __BORLANDC__
***************
*** 895,901 ****
        if (activewnd != NULL)
            /* restoring focus */
            SetForegroundWindow(activewnd);
!       if (consolewnd != NULL)
            FreeConsole();
  
  # endif
--- 919,925 ----
        if (activewnd != NULL)
            /* restoring focus */
            SetForegroundWindow(activewnd);
!         if (console_open)
            FreeConsole();
  
  # endif

Raspunde prin e-mail lui