changeset 1660:28775ce2d26c

Okay second attempt at that Windows 7 icon/bitmap fix... Last fix broke auto-sizing using HBITMAPS... this one seems to work for both HBITMAP and HICON but need to test on XP.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 16 Apr 2012 17:16:19 +0000
parents d06255e46ce2
children fc135161f2b1
files win/dw.c
diffstat 1 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/win/dw.c	Mon Apr 16 17:01:49 2012 +0000
+++ b/win/dw.c	Mon Apr 16 17:16:19 2012 +0000
@@ -4562,20 +4562,14 @@
       dw_free(buf);
    }
    
-   /* Attempt to get bitmap from classes that can have them */
+   /* Attempt to get icon from classes that can have them */
    if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1) == 0)
-   {
-      if(!(hic = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0)))
-         hbm = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
-   }
-   if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0)
-   {
-      if(!(hic = (HICON)SendMessage(handle, BM_GETIMAGE, IMAGE_ICON, 0)))
-         hbm = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0);
-   }
+      hic = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0);
+   else if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0)
+      hic = (HICON)SendMessage(handle, BM_GETIMAGE, IMAGE_ICON, 0);
       
    /* If we got an icon, pull out the internal bitmap */
-   if(hic && !hbm)
+   if(hic)
    {
       ICONINFO ii;
       
@@ -4583,6 +4577,16 @@
          hbm = ii.hbmMask ? ii.hbmMask : ii.hbmColor;
    }
    
+   /* If we weren't able to get the bitmap from the icon... */
+   if(!hbm)
+   {
+       /* Attempt to get bitmap from classes that can have them */
+      if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1) == 0)
+         hbm = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
+      else if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0)
+         hbm = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0);
+   }
+   
    /* If we got an image... set the sizes appropriately */
    if(hbm)
    {