Commit 4ac8db78 authored by Pierre Mageau's avatar Pierre Mageau Committed by Alexandre Julliard

Changed CopyImage to accept desiredX, desiredY and LR_COPYFROMRESOURCE.

CURSORICON_FindBestIcon changed to find the correct icon. ImageList_ReplaceIcon now calls CopyImage internally. Assign a value for the hIconSm CLASS member (using CopyImage).
parent 749a2c6c
......@@ -2104,6 +2104,7 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon)
{
HDC hdcImageList, hdcImage;
INT nIndex;
HICON hBestFitIcon;
HBITMAP hbmOldSrc, hbmOldDst;
ICONINFO ii;
BITMAP bmp;
......@@ -2115,7 +2116,12 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon)
if ((i >= himl->cCurImage) || (i < -1))
return -1;
GetIconInfo (hIcon, &ii);
hBestFitIcon = CopyImage(
hIcon, IMAGE_ICON,
himl->cx, himl->cy,
LR_COPYFROMRESOURCE);
GetIconInfo (hBestFitIcon, &ii);
if (ii.hbmMask == 0)
ERR("no mask!\n");
if (ii.hbmColor == 0)
......@@ -2159,6 +2165,8 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon)
SelectObject (hdcImage, hbmOldSrc);
SelectObject (hdcImageList, hbmOldDst);
if(hBestFitIcon)
DestroyIcon(hBestFitIcon);
if (hdcImageList)
DeleteDC (hdcImageList);
if (hdcImage)
......
......@@ -79,6 +79,10 @@ extern HGLOBAL CURSORICON_Load( HINSTANCE hInstance, LPCWSTR name,
int width, int height, int colors,
BOOL fCursor, UINT loadflags);
extern HGLOBAL CURSORICON_ExtCopy(HGLOBAL handle, UINT type,
INT desiredx, INT desiredy,
UINT flags);
extern WORD WINAPI CURSORICON_Destroy( HGLOBAL16 handle, UINT16 flags );
extern void CURSORICON_FreeModuleIcons( HMODULE hModule );
......
......@@ -238,6 +238,9 @@ BOOL WINAPI MAIN_UserInit(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserve
/* Initialize window procedures */
if (!WINPROC_Init()) return FALSE;
/* Initialize cursor/icons */
CURSORICON_Init();
/* Initialize built-in window classes */
if (!WIDGETS_Init()) return FALSE;
......@@ -247,9 +250,6 @@ BOOL WINAPI MAIN_UserInit(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserve
/* Initialize menus */
if (!MENU_Init()) return FALSE;
/* Initialize cursor/icons */
CURSORICON_Init();
/* Initialize message spying */
if (!SPY_Init()) return FALSE;
......
......@@ -527,8 +527,11 @@ HICON WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx,
case IMAGE_BITMAP:
return BITMAP_CopyBitmap(hnd);
case IMAGE_ICON:
return CopyIcon(hnd);
return CURSORICON_ExtCopy(hnd,type, desiredx, desiredy, flags);
case IMAGE_CURSOR:
/* Should call CURSORICON_ExtCopy but more testing
* needs to be done before we change this
*/
return CopyCursor(hnd);
}
return 0;
......
......@@ -412,6 +412,7 @@ ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc )
{
ATOM atom;
CLASS *classPtr;
int iSmIconWidth, iSmIconHeight;
HINSTANCE16 hInstance=GetExePtr(wc->hInstance);
if (!(atom = GlobalAddAtom16( wc->lpszClassName ))) return 0;
......@@ -431,8 +432,13 @@ ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc )
HIWORD(wc->lpszClassName) ?
(char *)PTR_SEG_TO_LIN(wc->lpszClassName) : "" );
iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
classPtr->hIcon = wc->hIcon;
classPtr->hIconSm = 0;
classPtr->hIconSm = CopyImage(wc->hIcon, IMAGE_ICON,
iSmIconWidth, iSmIconHeight,
LR_COPYFROMRESOURCE);
classPtr->hCursor = wc->hCursor;
classPtr->hbrBackground = wc->hbrBackground;
......@@ -455,6 +461,7 @@ ATOM WINAPI RegisterClassA(
const WNDCLASSA* wc /* Address of structure with class data */
) {
ATOM atom;
int iSmIconWidth, iSmIconHeight;
CLASS *classPtr;
if (!(atom = GlobalAddAtomA( wc->lpszClassName )))
......@@ -477,8 +484,13 @@ ATOM WINAPI RegisterClassA(
wc->cbWndExtra, classPtr,
HIWORD(wc->lpszClassName) ? wc->lpszClassName : "" );
classPtr->hIcon = (HICON16)wc->hIcon;
classPtr->hIconSm = 0;
iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
classPtr->hIcon = wc->hIcon;
classPtr->hIconSm = CopyImage(wc->hIcon, IMAGE_ICON,
iSmIconWidth, iSmIconHeight,
LR_COPYFROMRESOURCE);
classPtr->hCursor = (HCURSOR16)wc->hCursor;
classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
......@@ -494,6 +506,7 @@ ATOM WINAPI RegisterClassA(
ATOM WINAPI RegisterClassW( const WNDCLASSW* wc )
{
ATOM atom;
int iSmIconWidth, iSmIconHeight;
CLASS *classPtr;
if (!(atom = GlobalAddAtomW( wc->lpszClassName )))
......@@ -516,8 +529,13 @@ ATOM WINAPI RegisterClassW( const WNDCLASSW* wc )
wc->hbrBackground, wc->style, wc->cbClsExtra,
wc->cbWndExtra, classPtr );
classPtr->hIcon = (HICON16)wc->hIcon;
classPtr->hIconSm = 0;
iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
classPtr->hIcon = wc->hIcon;
classPtr->hIconSm = CopyImage(wc->hIcon, IMAGE_ICON,
iSmIconWidth, iSmIconHeight,
LR_COPYFROMRESOURCE);
classPtr->hCursor = (HCURSOR16)wc->hCursor;
classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment