Loading ...
Sorry, an error occurred while loading the content.

Make Vim run as a MDI Child window in Micosoft Visual Studio.

Expand Messages
  • Zhao, Zibo
    Hi, I m a newbie for the VIM dev group. I just did a little patch on the VIM 6.1 srouce code to make it run as a MDI child window instead of a pop up window.
    Message 1 of 2 , Oct 31, 2002
    • 0 Attachment
      Hi,

      I'm a newbie for the VIM dev group.
      I just did a little patch on the VIM 6.1 srouce code to make it run as a MDI child window instead of a pop up window.
      There are 2 ways to do that:
      1. I added a command line option -P to run the VIM as a MDI Child of MSDev. This way you can just install VIM as a customized tool to run it.
      2. Use VisVim.dll. This one will go through the OLE interface to enable the MDI Child creation for the MSDev. This one is more convenient, I think.

      Hope this is helpful.

      One of the drawback is that the menu is gone, I could not figure out how to get it out.
      But you can use command :te <menu name> to show the menu as separate window.

      Debugging with VIM is not working now. Sorry.

      The attached is the patch based on VIM 6.1 source.


      Zibo

      ********************************************
      ( _ ) Zibo Zhao
      o o ~~~~~~\ Email: zibo_zhao@...
      ( ) )~ Tel : (613) 592-5660 x6249
      ~ WW~~~WW Fax : (613) 592-7803
      Mitel Networks Corp.
      350 Legget Drive, P.O Box 13089
      Kanata, Ontario, K2K 2W7, Canada
      Web : http://www.mitel.com/
      ********************************************


      PATCH for gui_w32.c
      ________________________________________________________________________________
      --- src/gui_w32.c 2002-03-18 15:40:46.000000000 -0500
      +++ newsrc/gui_w32.c 2002-10-31 14:18:44.000000000 -0500
      @@ -29,6 +29,7 @@
      #include "gui_w48.c"


      +
      #ifdef __MINGW32__
      /*
      * Add a lot of missing defines.
      @@ -249,6 +250,18 @@
      # define pImmGetConversionStatus ImmGetConversionStatus
      #endif

      +
      +extern HWND vim_parent_hwnd;
      +//
      +// prototypes
      +//
      +extern BOOL CALLBACK
      +EnumWindowsProc(
      + HWND hwnd,
      + LPARAM lParam
      + );
      +
      +
      /*
      * Return TRUE when running under Windows NT 3.x or Win32s, both of which have
      * less fancy GUI APIs.
      @@ -896,6 +909,11 @@
      {
      #ifdef FEAT_OLE
      *argc = 1;
      + // MessageBox(0,"Invoked from OLE", "VIM", MB_OK);
      + // enumerate all windows to find the parent if possible
      + //
      + EnumWindows( EnumWindowsProc, (LPARAM) 0 );
      +
      #else
      ole_error("embedding");
      mch_exit(2);
      @@ -907,6 +925,7 @@
      {
      int bDoRestart = FALSE;

      +
      InitOLE(&bDoRestart);
      /* automatically exit after registering */
      if (bDoRestart)
      @@ -978,15 +997,31 @@
      return FAIL;
      }

      - s_hwnd = CreateWindow(
      - szVimWndClass, "Vim MSWindows GUI",
      - WS_OVERLAPPEDWINDOW,
      - gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
      - gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y,
      - 100, /* Any value will do */
      - 100, /* Any value will do */
      - NULL, NULL,
      - s_hinst, NULL);
      + if(vim_parent_hwnd != NULL)
      + {
      + s_hwnd = CreateWindowEx(
      + WS_EX_MDICHILD,
      + szVimWndClass, "Vim MSWindows GUI",
      + WS_OVERLAPPEDWINDOW | WS_CHILD | WS_CLIPSIBLINGS | 0xC000,
      + gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
      + gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y,
      + 100, /* Any value will do */
      + 100, /* Any value will do */
      + vim_parent_hwnd, NULL,
      + s_hinst, NULL);
      + }
      + else
      + {
      + s_hwnd = CreateWindow(
      + szVimWndClass, "Vim MSWindows GUI",
      + WS_OVERLAPPEDWINDOW,
      + gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
      + gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y,
      + 100, /* Any value will do */
      + 100, /* Any value will do */
      + NULL, NULL,
      + s_hinst, NULL);
      + }

      if (s_hwnd == NULL)
      return FAIL;
      @@ -1157,9 +1192,20 @@
      if (win_ypos < workarea_rect.top)
      win_ypos = workarea_rect.top;

      - /* set window position */
      - SetWindowPos(s_hwnd, NULL, win_xpos, win_ypos, win_width, win_height,
      - SWP_NOZORDER | SWP_NOACTIVATE);
      + if(vim_parent_hwnd != NULL)
      + {
      + /* set window position */
      + SetWindowPos(s_hwnd, NULL, win_xpos, win_ypos, win_width, win_height,
      + SWP_NOZORDER);
      + }
      + else
      + {
      + /* set window position */
      + SetWindowPos(s_hwnd, NULL, win_xpos, win_ypos, win_width, win_height,
      + SWP_NOZORDER | SWP_NOACTIVATE);
      + }
      + SetActiveWindow(s_hwnd);
      + SetFocus(s_hwnd);

      #ifdef FEAT_MENU
      /* Menu may wrap differently now */



      ________________________________________________________________________________
      PATCH for gui_w48.c
      ________________________________________________________________________________
      --- src/gui_w48.c 2002-03-21 15:30:56.000000000 -0500
      +++ newsrc/gui_w48.c 2002-10-31 14:13:46.000000000 -0500
      @@ -600,7 +600,13 @@
      int button = -1;
      int repeated_click;

      - if (s_uMsg == WM_LBUTTONDOWN || s_uMsg == WM_LBUTTONDBLCLK)
      + /*
      + * Give main window the focus back: this is so
      + * the cursor isn't hollow.
      + */
      + (void)SetFocus(s_hwnd);
      +
      + if (s_uMsg == WM_LBUTTONDOWN || s_uMsg == WM_LBUTTONDBLCLK)
      button = MOUSE_LEFT;
      else if (s_uMsg == WM_MBUTTONDOWN || s_uMsg == WM_MBUTTONDBLCLK)
      button = MOUSE_MIDDLE;
      @@ -1842,6 +1848,10 @@
      gui_mch_enable_menu(int flag)
      {
      #ifdef FEAT_MENU
      + if(!flag)
      + {
      + MessageBox(0,"Removing the menu?", "VIM", MB_OK);
      + }
      SetMenu(s_hwnd, flag ? s_menuBar : NULL);
      #endif
      }


      ________________________________________________________________________________
      PATCH for main.c
      ________________________________________________________________________________
      --- src/main.c 2002-03-24 06:05:18.000000000 -0500
      +++ newsrc/main.c 2002-10-31 12:42:17.000000000 -0500
      @@ -11,6 +11,70 @@
      # include <io.h> /* for close() and dup() */
      #endif

      +#if defined(WIN32)
      +# include <windows.h>
      +HWND vim_parent_hwnd = NULL;
      +//
      +// prototypes
      +//
      +BOOL CALLBACK
      +EnumWindowsProc(
      + HWND hwnd,
      + LPARAM lParam
      + );
      +
      +BOOL CALLBACK
      +EnumWindowsProc(
      + HWND hwnd,
      + LPARAM lParam
      + )
      +
      +/*++
      +
      +Routine Description:
      +
      + Callback function for window enumeration.
      +
      +Arguments:
      +
      + hwnd - window handle
      + lParam - ** not used **
      +
      +Return Value:
      +
      + TRUE - continues the enumeration
      +
      +--*/
      +
      +{
      + CHAR buf[2048];
      + CHAR *SearchTitle = "Microsoft Visual C++";
      + // CHAR *SearchTitle = "Tornado";
      + //
      + // look for the task in the task list for this window
      + //
      + // window text
      + //
      + if (GetWindowText( hwnd, buf, sizeof(buf) ))
      + {
      + //
      + // got it, so lets save it
      + //
      + if(strstr(buf, SearchTitle ))
      + {
      + vim_parent_hwnd = FindWindowEx(hwnd, NULL, "MDIClient", NULL);
      + return FALSE;
      + }
      + }
      + //
      + // continue the enumeration
      + //
      + return TRUE;
      +}
      +
      +
      +#endif
      +
      #define EXTERN
      #include "vim.h"

      @@ -695,6 +759,22 @@
      #endif
      break;

      +#if defined(WIN32)
      + case 'P': /* "-P" Set the parent window to whatever string is*/
      + /* default is 0: no parent window */
      + {
      + //
      + // enumerate all windows to find the parent if possible
      + //
      + EnumWindows( EnumWindowsProc, (LPARAM) 0 );
      +
      + // sprintf(buffer, "vim_parent_hwnd has been set to 0x%lx\n", vim_parent_hwnd);
      + // MessageBox(0,buffer, "Message", MB_OK);
      + }
      + break;
      +
      +#endif
      +
      #ifdef FEAT_QUICKFIX
      case 'q': /* "-q" QuickFix mode */
      if (edit_type != EDIT_NONE)
      @@ -2264,6 +2344,10 @@

      mch_msg(_("\n\nArguments:\n"));
      main_msg(_("--\t\t\tOnly file names after this"));
      +#if defined(WIN32)
      + main_msg(_("-P[HWND]\t\tSet the parent window "));
      +#endif
      +
      #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE)
      main_msg(_("--literal\t\tDon't expand wildcards"));
      #endif
    • Bram Moolenaar
      ... Several people have been asking for this. Looks like a nice solution. Perhaps some people can try it out and tell us for what version(s) of devstudio this
      Message 2 of 2 , Nov 1, 2002
      • 0 Attachment
        Zibo Zhao wrote:

        > I'm a newbie for the VIM dev group.
        > I just did a little patch on the VIM 6.1 srouce code to make it run as
        > a MDI child window instead of a pop up window.
        > There are 2 ways to do that:
        > 1. I added a command line option -P to run the VIM as a MDI Child of
        > MSDev. This way you can just install VIM as a customized tool to run
        > it.
        > 2. Use VisVim.dll. This one will go through the OLE interface to
        > enable the MDI Child creation for the MSDev. This one is more
        > convenient, I think.
        >
        > Hope this is helpful.
        >
        > One of the drawback is that the menu is gone, I could not figure out
        > how to get it out. But you can use command :te <menu name> to show
        > the menu as separate window.
        >
        > Debugging with VIM is not working now. Sorry.
        >
        > The attached is the patch based on VIM 6.1 source.

        Several people have been asking for this. Looks like a nice solution.
        Perhaps some people can try it out and tell us for what version(s) of
        devstudio this works.

        --
        [Another hideous roar.]
        BEDEVERE: That's it!
        ARTHUR: What?
        BEDEVERE: It's The Legendary Black Beast of Aaaaarrrrrrggghhh!
        "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

        /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
        /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\
        \\\ Project leader for A-A-P -- http://www.a-a-p.org ///
        \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///
      Your message has been successfully submitted and would be delivered to recipients shortly.