user32: Move loading of static icons for 16-bit windows to the 16-bit wrapper.

oldstable
Alexandre Julliard 2009-12-28 19:53:12 +01:00
parent fadc2cda1c
commit b96ab35cad
2 changed files with 69 additions and 73 deletions

View File

@ -2594,6 +2594,33 @@ static LRESULT static_proc16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
{
switch (msg)
{
case WM_NCCREATE:
{
CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
LRESULT ret = wow_handlers32.static_proc( hwnd, msg, wParam, lParam, unicode );
if (!ret) return 0;
if (((ULONG_PTR)cs->hInstance >> 16)) return ret; /* 32-bit instance, nothing to do */
switch (cs->style & SS_TYPEMASK)
{
case SS_ICON:
{
HICON16 icon = LoadIcon16( HINSTANCE_16(cs->hInstance), cs->lpszName );
if (!icon) icon = LoadCursor16( HINSTANCE_16(cs->hInstance), cs->lpszName );
if (icon) wow_handlers32.static_proc( hwnd, STM_SETIMAGE, IMAGE_ICON,
(LPARAM)HICON_32(icon), FALSE );
break;
}
case SS_BITMAP:
{
HBITMAP16 bitmap = LoadBitmap16( HINSTANCE_16(cs->hInstance), cs->lpszName );
if (bitmap) wow_handlers32.static_proc( hwnd, STM_SETIMAGE, IMAGE_BITMAP,
(LPARAM)HBITMAP_32(bitmap), FALSE );
break;
}
}
return ret;
}
case STM_SETICON16:
wParam = (WPARAM)HICON_32( (HICON16)wParam );
return wow_handlers32.static_proc( hwnd, STM_SETICON, wParam, lParam, FALSE );

View File

@ -256,23 +256,25 @@ static HANDLE STATIC_GetImage( HWND hwnd, WPARAM wParam, DWORD style )
*
* Load the icon for an SS_ICON control.
*/
static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name, DWORD style )
static HICON STATIC_LoadIconA( HINSTANCE hInstance, LPCSTR name, DWORD style )
{
HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
if ((style & SS_REALSIZEIMAGE) != 0)
HICON hicon;
if (hInstance && ((ULONG_PTR)hInstance >> 16))
{
return LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
}
else
{
HICON hicon = LoadIconA( hInstance, name );
if (!hicon) hicon = LoadCursorA( hInstance, name );
if (!hicon) hicon = LoadIconA( 0, name );
/* Windows doesn't try to load a standard cursor,
probably because most IDs for standard cursors conflict
with the IDs for standard icons anyway */
return hicon;
if ((style & SS_REALSIZEIMAGE) != 0)
hicon = LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
else
{
hicon = LoadIconA( hInstance, name );
if (!hicon) hicon = LoadCursorA( hInstance, name );
}
}
if (!hicon) hicon = LoadIconA( 0, name );
/* Windows doesn't try to load a standard cursor,
probably because most IDs for standard cursors conflict
with the IDs for standard icons anyway */
return hicon;
}
/***********************************************************************
@ -280,47 +282,25 @@ static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name, DWORD style )
*
* Load the icon for an SS_ICON control.
*/
static HICON STATIC_LoadIconW( HWND hwnd, LPCWSTR name, DWORD style )
static HICON STATIC_LoadIconW( HINSTANCE hInstance, LPCWSTR name, DWORD style )
{
HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
if ((style & SS_REALSIZEIMAGE) != 0)
{
return LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
}
else
{
HICON hicon = LoadIconW( hInstance, name );
if (!hicon) hicon = LoadCursorW( hInstance, name );
if (!hicon) hicon = LoadIconW( 0, name );
/* Windows doesn't try to load a standard cursor,
probably because most IDs for standard cursors conflict
with the IDs for standard icons anyway */
return hicon;
}
}
HICON hicon;
/***********************************************************************
* STATIC_LoadBitmapA
*
* Load the bitmap for an SS_BITMAP control.
*/
static HBITMAP STATIC_LoadBitmapA( HWND hwnd, LPCSTR name )
{
HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
/* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
return LoadBitmapA( hInstance, name );
}
/***********************************************************************
* STATIC_LoadBitmapW
*
* Load the bitmap for an SS_BITMAP control.
*/
static HBITMAP STATIC_LoadBitmapW( HWND hwnd, LPCWSTR name )
{
HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
/* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
return LoadBitmapW( hInstance, name );
if (hInstance && ((ULONG_PTR)hInstance >> 16))
{
if ((style & SS_REALSIZEIMAGE) != 0)
hicon = LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
else
{
hicon = LoadIconW( hInstance, name );
if (!hicon) hicon = LoadCursorW( hInstance, name );
}
}
if (!hicon) hicon = LoadIconW( 0, name );
/* Windows doesn't try to load a standard cursor,
probably because most IDs for standard cursors conflict
with the IDs for standard icons anyway */
return hicon;
}
/***********************************************************************
@ -471,42 +451,31 @@ LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam
case WM_NCCREATE:
{
LPCSTR textA;
LPCWSTR textW;
CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
if (full_style & SS_SUNKEN)
SetWindowLongW( hwnd, GWL_EXSTYLE,
GetWindowLongW( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE );
if(unicode)
{
textA = NULL;
textW = ((LPCREATESTRUCTW)lParam)->lpszName;
}
else
{
textA = ((LPCREATESTRUCTA)lParam)->lpszName;
textW = NULL;
}
switch (style) {
case SS_ICON:
{
HICON hIcon;
if(unicode)
hIcon = STATIC_LoadIconW(hwnd, textW, full_style);
if (unicode || IS_INTRESOURCE(cs->lpszName))
hIcon = STATIC_LoadIconW(cs->hInstance, cs->lpszName, full_style);
else
hIcon = STATIC_LoadIconA(hwnd, textA, full_style);
hIcon = STATIC_LoadIconA(cs->hInstance, (LPCSTR)cs->lpszName, full_style);
STATIC_SetIcon(hwnd, hIcon, full_style);
}
break;
case SS_BITMAP:
if ((ULONG_PTR)cs->hInstance >> 16)
{
HBITMAP hBitmap;
if(unicode)
hBitmap = STATIC_LoadBitmapW(hwnd, textW);
if (unicode || IS_INTRESOURCE(cs->lpszName))
hBitmap = LoadBitmapW(cs->hInstance, cs->lpszName);
else
hBitmap = STATIC_LoadBitmapA(hwnd, textA);
hBitmap = LoadBitmapA(cs->hInstance, (LPCSTR)cs->lpszName);
STATIC_SetBitmap(hwnd, hBitmap, full_style);
}
break;