Blame SOURCES/7.4.459

22c937
To: vim_dev@googlegroups.com
22c937
Subject: Patch 7.4.459
22c937
Fcc: outbox
22c937
From: Bram Moolenaar <Bram@moolenaar.net>
22c937
Mime-Version: 1.0
22c937
Content-Type: text/plain; charset=UTF-8
22c937
Content-Transfer-Encoding: 8bit
22c937
------------
22c937
22c937
Patch 7.4.459
22c937
Problem:    Can't change the icon after building Vim.
22c937
Solution:   Load the icon from a file on startup. (Yasuhiro Matsumoto)
22c937
Files:      src/gui_w32.c, src/os_mswin.c, src/os_win32.c, 
22c937
            src/proto/os_mswin.pro
22c937
22c937
22c937
*** ../vim-7.4.458/src/gui_w32.c	2014-09-19 16:13:48.358419065 +0200
22c937
--- src/gui_w32.c	2014-09-23 21:53:17.382849313 +0200
22c937
***************
22c937
*** 1662,1667 ****
22c937
--- 1662,1675 ----
22c937
      if (s_textArea == NULL)
22c937
  	return FAIL;
22c937
  
22c937
+     /* Try loading an icon from $RUNTIMEPATH/bitmaps/vim.ico. */
22c937
+     {
22c937
+ 	HANDLE	hIcon = NULL;
22c937
+ 
22c937
+ 	if (mch_icon_load(&hIcon) == OK && hIcon != NULL)
22c937
+ 	    SendMessage(s_hwnd, WM_SETICON, ICON_SMALL, hIcon);
22c937
+     }
22c937
+ 
22c937
  #ifdef FEAT_MENU
22c937
      s_menuBar = CreateMenu();
22c937
  #endif
22c937
*** ../vim-7.4.458/src/os_mswin.c	2014-09-09 12:25:27.768501863 +0200
22c937
--- src/os_mswin.c	2014-09-23 21:52:50.582849254 +0200
22c937
***************
22c937
*** 928,933 ****
22c937
--- 928,960 ----
22c937
  }
22c937
  # endif
22c937
  
22c937
+ /*
22c937
+  * Passed to do_in_runtimepath() to load a vim.ico file.
22c937
+  */
22c937
+     static void
22c937
+ mch_icon_load_cb(char_u *fname, void *cookie)
22c937
+ {
22c937
+     HANDLE *h = (HANDLE *)cookie;
22c937
+ 
22c937
+     *h = LoadImage(NULL,
22c937
+ 		   fname,
22c937
+ 		   IMAGE_ICON,
22c937
+ 		   64,
22c937
+ 		   64,
22c937
+ 		   LR_LOADFROMFILE | LR_LOADMAP3DCOLORS);
22c937
+ }
22c937
+ 
22c937
+ /*
22c937
+  * Try loading an icon file from 'runtimepath'.
22c937
+  */
22c937
+     int
22c937
+ mch_icon_load(iconp)
22c937
+     HANDLE *iconp;
22c937
+ {
22c937
+     return do_in_runtimepath((char_u *)"bitmaps/vim.ico",
22c937
+ 					      FALSE, mch_icon_load_cb, iconp);
22c937
+ }
22c937
+ 
22c937
      int
22c937
  mch_libcall(
22c937
      char_u	*libname,
22c937
*** ../vim-7.4.458/src/os_win32.c	2014-09-09 12:25:27.764501863 +0200
22c937
--- src/os_win32.c	2014-09-23 21:47:03.318848496 +0200
22c937
***************
22c937
*** 2446,2452 ****
22c937
  	return;
22c937
  
22c937
      /* Extract the first icon contained in the Vim executable. */
22c937
!     g_hVimIcon = ExtractIcon(NULL, exe_name, 0);
22c937
      if (g_hVimIcon != NULL)
22c937
  	g_fCanChangeIcon = TRUE;
22c937
  }
22c937
--- 2446,2453 ----
22c937
  	return;
22c937
  
22c937
      /* Extract the first icon contained in the Vim executable. */
22c937
!     if (mch_icon_load((HANDLE *)&g_hVimIcon) == FAIL || g_hVimIcon == NULL)
22c937
! 	g_hVimIcon = ExtractIcon(NULL, exe_name, 0);
22c937
      if (g_hVimIcon != NULL)
22c937
  	g_fCanChangeIcon = TRUE;
22c937
  }
22c937
*** ../vim-7.4.458/src/proto/os_mswin.pro	2013-08-10 13:37:39.000000000 +0200
22c937
--- src/proto/os_mswin.pro	2014-09-23 21:49:29.746848816 +0200
22c937
***************
22c937
*** 21,26 ****
22c937
--- 21,27 ----
22c937
  int mch_chdir __ARGS((char *path));
22c937
  int can_end_termcap_mode __ARGS((int give_msg));
22c937
  int mch_screenmode __ARGS((char_u *arg));
22c937
+ int mch_icon_load __ARGS((HANDLE *iconp));
22c937
  int mch_libcall __ARGS((char_u *libname, char_u *funcname, char_u *argstring, int argint, char_u **string_result, int *number_result));
22c937
  void DumpPutS __ARGS((const char *psz));
22c937
  int mch_get_winpos __ARGS((int *x, int *y));
22c937
*** ../vim-7.4.458/src/version.c	2014-09-23 18:37:52.426823701 +0200
22c937
--- src/version.c	2014-09-23 21:36:07.806847064 +0200
22c937
***************
22c937
*** 743,744 ****
22c937
--- 743,746 ----
22c937
  {   /* Add new patch number below this line */
22c937
+ /**/
22c937
+     459,
22c937
  /**/
22c937
22c937
-- 
22c937
If Microsoft would build a car...
22c937
... You'd have to press the "Start" button to turn the engine off.
22c937
22c937
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
22c937
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
22c937
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
22c937
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///