mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 04:13:31 +00:00
[USER32]
- Fix bug in CreateIconIndirect - implement get_icon_size - use unmodified wine code for STATIC_PaintIconfn svn path=/trunk/; revision=50406
This commit is contained in:
@@ -845,35 +845,28 @@ static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style )
|
||||
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 @@ static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,3 +10,6 @@ HICON CreateCursorIconFromData(PVOID ImageData,
|
||||
int yHotspot,
|
||||
BOOL fIcon);
|
||||
|
||||
|
||||
BOOL get_icon_size(HICON hIcon, SIZE *size);
|
||||
|
||||
|
||||
@@ -1477,8 +1477,9 @@ HICON WINAPI CreateIconIndirect(PICONINFO iconinfo)
|
||||
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 @@ HICON WINAPI CreateIconIndirect(PICONINFO iconinfo)
|
||||
}
|
||||
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 @@ User32SetupDefaultCursors(PVOID Arguments,
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user