Author: tkreuzer Date: Sun Jan 16 21:41:47 2011 New Revision: 50406
URL: http://svn.reactos.org/svn/reactos?rev=50406&view=rev Log: [USER32] - Fix bug in CreateIconIndirect - implement get_icon_size - use unmodified wine code for STATIC_PaintIconfn
Modified: trunk/reactos/dll/win32/user32/controls/static.c trunk/reactos/dll/win32/user32/include/cursor.h trunk/reactos/dll/win32/user32/windows/cursoricon.c
Modified: trunk/reactos/dll/win32/user32/controls/static.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/controls/s... ============================================================================== --- trunk/reactos/dll/win32/user32/controls/static.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/controls/static.c [iso-8859-1] Sun Jan 16 21:41:47 2011 @@ -845,35 +845,28 @@ DeleteObject( hBrush ); }
-/* Modified for ReactOS */ static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style ) { RECT rc, iconRect; HBRUSH hbrush; HICON hIcon; - ICONINFO info; + SIZE size;
GetClientRect( hwnd, &rc ); hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc); hIcon = (HICON)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET ); - if (!hIcon || (!GetIconInfo(hIcon, &info))) + if (!hIcon || !get_icon_size( hIcon, &size )) { FillRect(hdc, &rc, hbrush); } else { - BITMAP bm; - GetObjectW(info.hbmMask, sizeof(BITMAP), &bm); - if (!info.fIcon) - { - bm.bmHeight /= 2; - } if (style & SS_CENTERIMAGE) { - iconRect.left = (rc.right - rc.left) / 2 - bm.bmWidth / 2; - iconRect.top = (rc.bottom - rc.top) / 2 - bm.bmHeight / 2; - iconRect.right = iconRect.left + bm.bmWidth; - iconRect.bottom = iconRect.top + bm.bmHeight; + iconRect.left = (rc.right - rc.left) / 2 - size.cx / 2; + iconRect.top = (rc.bottom - rc.top) / 2 - size.cy / 2; + iconRect.right = iconRect.left + size.cx; + iconRect.bottom = iconRect.top + size.cy; } else iconRect = rc; @@ -970,3 +963,4 @@ break; } } +
Modified: trunk/reactos/dll/win32/user32/include/cursor.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/cu... ============================================================================== --- trunk/reactos/dll/win32/user32/include/cursor.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/include/cursor.h [iso-8859-1] Sun Jan 16 21:41:47 2011 @@ -10,3 +10,6 @@ int yHotspot, BOOL fIcon);
+ +BOOL get_icon_size(HICON hIcon, SIZE *size); +
Modified: trunk/reactos/dll/win32/user32/windows/cursoricon.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/cu... ============================================================================== --- trunk/reactos/dll/win32/user32/windows/cursoricon.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/cursoricon.c [iso-8859-1] Sun Jan 16 21:41:47 2011 @@ -1477,8 +1477,9 @@ bmpXor.bmWidth, bmpXor.bmHeight, bmpXor.bmWidthBytes, bmpXor.bmPlanes, bmpXor.bmBitsPixel);
- width = bmpXor.bmWidth; - height = bmpXor.bmHeight; + // the size of the mask bitmap always determines the icon size! + width = bmpAnd.bmWidth; + height = bmpAnd.bmHeight; if (bmpXor.bmPlanes * bmpXor.bmBitsPixel != 1) { color = CreateBitmap( width, height, bmpXor.bmPlanes, bmpXor.bmBitsPixel, NULL ); @@ -1497,7 +1498,7 @@ } else { - mask = CreateBitmap( width, height * 2, 1, 1, NULL ); + mask = CreateBitmap( width, height, 1, 1, NULL ); if(!mask) { ERR("Unable to create mask bitmap!\n"); @@ -2181,3 +2182,23 @@
return(ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS)); } + +BOOL get_icon_size(HICON hIcon, SIZE *size) +{ + ICONINFO info; + BITMAP bitmap; + + if (!GetIconInfo(hIcon, &info)) return FALSE; + if (!GetObject(info.hbmMask, sizeof(bitmap), &bitmap)) return FALSE; + + size->cx = bitmap.bmWidth; + size->cy = bitmap.bmHeight; + + /* Black and white icons store both the XOR and AND bitmap in hbmMask */ + if (!info.hbmColor) + { + size->cy /= 2; + } + + return TRUE; +}