mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 14:23:18 +00:00
- Make the file at least slightly readable (the mixed TABs and spaces were way too annoying).
- Replace GetModuleHandleW(L"user32.dll") with User32Instance. - Fix one more allocation check. svn path=/trunk/; revision=20121
This commit is contained in:
parent
e5b6313286
commit
fca11cd62d
1 changed files with 297 additions and 378 deletions
|
@ -66,7 +66,8 @@ LoadImageA(HINSTANCE hinst,
|
||||||
Handle = LoadImageW(hinst, (LPCWSTR)lpszName, uType, cxDesired,
|
Handle = LoadImageW(hinst, (LPCWSTR)lpszName, uType, cxDesired,
|
||||||
cyDesired, fuLoad);
|
cyDesired, fuLoad);
|
||||||
}
|
}
|
||||||
return(Handle);
|
|
||||||
|
return Handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,35 +95,27 @@ LoadCursorImage(HINSTANCE hinst, LPCWSTR lpszName, UINT fuLoad)
|
||||||
if (!(fuLoad & LR_LOADFROMFILE))
|
if (!(fuLoad & LR_LOADFROMFILE))
|
||||||
{
|
{
|
||||||
if (hinst == NULL)
|
if (hinst == NULL)
|
||||||
{
|
hinst = User32Instance;
|
||||||
hinst = GetModuleHandleW(L"USER32");
|
|
||||||
}
|
|
||||||
hResource = hfRes = FindResourceW(hinst, lpszName, RT_GROUP_CURSOR);
|
hResource = hfRes = FindResourceW(hinst, lpszName, RT_GROUP_CURSOR);
|
||||||
if (hResource == NULL)
|
if (hResource == NULL)
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (fuLoad & LR_SHARED)
|
if (fuLoad & LR_SHARED)
|
||||||
{
|
{
|
||||||
/* FIXME - pass size! */
|
/* FIXME - pass size! */
|
||||||
hIcon = (HANDLE)NtUserFindExistingCursorIcon(hinst, (HRSRC)hfRes, 0, 0);
|
hIcon = (HANDLE)NtUserFindExistingCursorIcon(hinst, (HRSRC)hfRes, 0, 0);
|
||||||
if (hIcon)
|
if (hIcon)
|
||||||
{
|
|
||||||
return hIcon;
|
return hIcon;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
hResource = LoadResource(hinst, hResource);
|
hResource = LoadResource(hinst, hResource);
|
||||||
if (hResource == NULL)
|
if (hResource == NULL)
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
IconResDir = LockResource(hResource);
|
IconResDir = LockResource(hResource);
|
||||||
if (IconResDir == NULL)
|
if (IconResDir == NULL)
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the best fitting in the IconResDir for this resolution. */
|
/* Find the best fitting in the IconResDir for this resolution. */
|
||||||
id = LookupIconIdFromDirectoryEx((PBYTE)IconResDir, TRUE,
|
id = LookupIconIdFromDirectoryEx((PBYTE)IconResDir, TRUE,
|
||||||
|
@ -133,15 +126,11 @@ LoadCursorImage(HINSTANCE hinst, LPCWSTR lpszName, UINT fuLoad)
|
||||||
|
|
||||||
hResource = LoadResource(hinst, h2Resource);
|
hResource = LoadResource(hinst, h2Resource);
|
||||||
if (hResource == NULL)
|
if (hResource == NULL)
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
ResIcon = LockResource(hResource);
|
ResIcon = LockResource(hResource);
|
||||||
if (ResIcon == NULL)
|
if (ResIcon == NULL)
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
hIcon = (HANDLE)CreateIconFromResourceEx((PBYTE)ResIcon,
|
hIcon = (HANDLE)CreateIconFromResourceEx((PBYTE)ResIcon,
|
||||||
SizeofResource(hinst, h2Resource), FALSE, 0x00030000,
|
SizeofResource(hinst, h2Resource), FALSE, 0x00030000,
|
||||||
|
@ -163,23 +152,17 @@ LoadCursorImage(HINSTANCE hinst, LPCWSTR lpszName, UINT fuLoad)
|
||||||
hFile = CreateFileW(lpszName, GENERIC_READ, FILE_SHARE_READ, NULL,
|
hFile = CreateFileW(lpszName, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||||
OPEN_EXISTING, 0, NULL);
|
OPEN_EXISTING, 0, NULL);
|
||||||
if (hFile == NULL)
|
if (hFile == NULL)
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
hSection = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
|
hSection = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
if (hSection == NULL)
|
if (hSection == NULL)
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
IconDIR = MapViewOfFile(hSection, FILE_MAP_READ, 0, 0, 0);
|
IconDIR = MapViewOfFile(hSection, FILE_MAP_READ, 0, 0, 0);
|
||||||
CloseHandle(hSection);
|
CloseHandle(hSection);
|
||||||
if (IconDIR == NULL)
|
if (IconDIR == NULL)
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (0 != IconDIR->idReserved ||
|
if (0 != IconDIR->idReserved ||
|
||||||
(IMAGE_ICON != IconDIR->idType && IMAGE_CURSOR != IconDIR->idType))
|
(IMAGE_ICON != IconDIR->idType && IMAGE_CURSOR != IconDIR->idType))
|
||||||
|
@ -192,7 +175,7 @@ LoadCursorImage(HINSTANCE hinst, LPCWSTR lpszName, UINT fuLoad)
|
||||||
* Get a handle to the screen dc, the icon we create is going to be
|
* Get a handle to the screen dc, the icon we create is going to be
|
||||||
* compatable with it.
|
* compatable with it.
|
||||||
*/
|
*/
|
||||||
hScreenDc = CreateCompatibleDC(0);
|
hScreenDc = CreateCompatibleDC(NULL);
|
||||||
if (hScreenDc == NULL)
|
if (hScreenDc == NULL)
|
||||||
{
|
{
|
||||||
UnmapViewOfFile(IconDIR);
|
UnmapViewOfFile(IconDIR);
|
||||||
|
@ -245,9 +228,7 @@ LoadCursorImage(HINSTANCE hinst, LPCWSTR lpszName, UINT fuLoad)
|
||||||
{
|
{
|
||||||
ColorCount = SafeIconImage->icHeader.biClrUsed;
|
ColorCount = SafeIconImage->icHeader.biClrUsed;
|
||||||
if (ColorCount == 0 && SafeIconImage->icHeader.biBitCount <= 8)
|
if (ColorCount == 0 && SafeIconImage->icHeader.biBitCount <= 8)
|
||||||
{
|
|
||||||
ColorCount = 1 << SafeIconImage->icHeader.biBitCount;
|
ColorCount = 1 << SafeIconImage->icHeader.biBitCount;
|
||||||
}
|
|
||||||
HeaderSize = sizeof(BITMAPINFOHEADER) + ColorCount * sizeof(RGBQUAD);
|
HeaderSize = sizeof(BITMAPINFOHEADER) + ColorCount * sizeof(RGBQUAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,6 +238,7 @@ LoadCursorImage(HINSTANCE hinst, LPCWSTR lpszName, UINT fuLoad)
|
||||||
hIcon = ICON_CreateCursorFromData(hScreenDc, Data, SafeIconImage, 32, 32, dirEntry->Info.cursor.wXHotspot, dirEntry->Info.cursor.wYHotspot);
|
hIcon = ICON_CreateCursorFromData(hScreenDc, Data, SafeIconImage, 32, 32, dirEntry->Info.cursor.wXHotspot, dirEntry->Info.cursor.wYHotspot);
|
||||||
DeleteDC(hScreenDc);
|
DeleteDC(hScreenDc);
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, SafeIconImage);
|
RtlFreeHeap(GetProcessHeap(), 0, SafeIconImage);
|
||||||
|
|
||||||
return hIcon;
|
return hIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +253,7 @@ LoadIconImage(HINSTANCE hinst, LPCWSTR lpszName, INT width, INT height, UINT fuL
|
||||||
HANDLE hSection;
|
HANDLE hSection;
|
||||||
CURSORICONDIR* IconDIR;
|
CURSORICONDIR* IconDIR;
|
||||||
HDC hScreenDc;
|
HDC hScreenDc;
|
||||||
HANDLE hIcon;
|
HICON hIcon;
|
||||||
ULONG HeaderSize;
|
ULONG HeaderSize;
|
||||||
ULONG ColorCount;
|
ULONG ColorCount;
|
||||||
PVOID Data;
|
PVOID Data;
|
||||||
|
@ -284,14 +266,11 @@ LoadIconImage(HINSTANCE hinst, LPCWSTR lpszName, INT width, INT height, UINT fuL
|
||||||
if (!(fuLoad & LR_LOADFROMFILE))
|
if (!(fuLoad & LR_LOADFROMFILE))
|
||||||
{
|
{
|
||||||
if (hinst == NULL)
|
if (hinst == NULL)
|
||||||
{
|
hinst = User32Instance;
|
||||||
hinst = GetModuleHandleW(L"USER32");
|
|
||||||
}
|
|
||||||
hResource = hfRes = FindResourceW(hinst, lpszName, RT_GROUP_ICON);
|
hResource = hfRes = FindResourceW(hinst, lpszName, RT_GROUP_ICON);
|
||||||
if (hResource == NULL)
|
if (hResource == NULL)
|
||||||
{
|
return NULL;
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fuLoad & LR_SHARED)
|
if (fuLoad & LR_SHARED)
|
||||||
{
|
{
|
||||||
|
@ -302,46 +281,42 @@ LoadIconImage(HINSTANCE hinst, LPCWSTR lpszName, INT width, INT height, UINT fuL
|
||||||
|
|
||||||
hResource = LoadResource(hinst, hResource);
|
hResource = LoadResource(hinst, hResource);
|
||||||
if (hResource == NULL)
|
if (hResource == NULL)
|
||||||
{
|
return NULL;
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
IconResDir = LockResource(hResource);
|
IconResDir = LockResource(hResource);
|
||||||
if (IconResDir == NULL)
|
if (IconResDir == NULL)
|
||||||
{
|
return NULL;
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
//find the best fitting in the IconResDir for this resolution
|
/*
|
||||||
id = LookupIconIdFromDirectoryEx((PBYTE) IconResDir, TRUE,
|
* Find the best fitting in the IconResDir for this resolution
|
||||||
width, height, fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME));
|
*/
|
||||||
|
|
||||||
h2Resource = FindResourceW(hinst,
|
id = LookupIconIdFromDirectoryEx((PBYTE)IconResDir, TRUE, width, height,
|
||||||
MAKEINTRESOURCEW(id),
|
fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME));
|
||||||
MAKEINTRESOURCEW(RT_ICON));
|
|
||||||
|
h2Resource = FindResourceW(hinst, MAKEINTRESOURCEW(id), MAKEINTRESOURCEW(RT_ICON));
|
||||||
|
|
||||||
hResource = LoadResource(hinst, h2Resource);
|
hResource = LoadResource(hinst, h2Resource);
|
||||||
if (hResource == NULL)
|
if (hResource == NULL)
|
||||||
{
|
return NULL;
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
ResIcon = LockResource(hResource);
|
ResIcon = LockResource(hResource);
|
||||||
if (ResIcon == NULL)
|
if (ResIcon == NULL)
|
||||||
{
|
return NULL;
|
||||||
return(NULL);
|
|
||||||
}
|
hIcon = CreateIconFromResourceEx((PBYTE)ResIcon,
|
||||||
hIcon = (HANDLE)CreateIconFromResourceEx((PBYTE) ResIcon,
|
SizeofResource(hinst, h2Resource),
|
||||||
SizeofResource(hinst, h2Resource), TRUE, 0x00030000,
|
TRUE, 0x00030000, width, height,
|
||||||
width, height, fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME));
|
fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME));
|
||||||
if (hIcon && 0 != (fuLoad & LR_SHARED))
|
if (hIcon && 0 != (fuLoad & LR_SHARED))
|
||||||
{
|
{
|
||||||
NtUserSetCursorIconData((HICON)hIcon, NULL, NULL, hinst, (HRSRC)hfRes,
|
NtUserSetCursorIconData((HICON)hIcon, NULL, NULL, hinst, (HRSRC)hfRes,
|
||||||
(HRSRC)NULL);
|
(HRSRC)NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hIcon;
|
return hIcon;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* FIXME: This code is incorrect and is likely to crash in many cases.
|
* FIXME: This code is incorrect and is likely to crash in many cases.
|
||||||
* In the file the cursor/icon directory records are stored like
|
* In the file the cursor/icon directory records are stored like
|
||||||
|
@ -355,41 +330,20 @@ LoadIconImage(HINSTANCE hinst, LPCWSTR lpszName, INT width, INT height, UINT fuL
|
||||||
DbgPrint("FIXME: need LR_SHARED support for loading icon images from files\n");
|
DbgPrint("FIXME: need LR_SHARED support for loading icon images from files\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
hFile = CreateFileW(lpszName,
|
hFile = CreateFileW(lpszName, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||||
GENERIC_READ,
|
OPEN_EXISTING, 0, NULL);
|
||||||
FILE_SHARE_READ,
|
|
||||||
NULL,
|
|
||||||
OPEN_EXISTING,
|
|
||||||
0,
|
|
||||||
NULL);
|
|
||||||
if (hFile == NULL)
|
if (hFile == NULL)
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
hSection = CreateFileMappingW(hFile,
|
|
||||||
NULL,
|
|
||||||
PAGE_READONLY,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
|
hSection = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
if (hSection == NULL)
|
if (hSection == NULL)
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
IconDIR = MapViewOfFile(hSection,
|
IconDIR = MapViewOfFile(hSection, FILE_MAP_READ, 0, 0, 0);
|
||||||
FILE_MAP_READ,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
CloseHandle(hSection);
|
CloseHandle(hSection);
|
||||||
if (IconDIR == NULL)
|
if (IconDIR == NULL)
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (0 != IconDIR->idReserved ||
|
if (0 != IconDIR->idReserved ||
|
||||||
(IMAGE_ICON != IconDIR->idType && IMAGE_CURSOR != IconDIR->idType))
|
(IMAGE_ICON != IconDIR->idType && IMAGE_CURSOR != IconDIR->idType))
|
||||||
|
@ -398,7 +352,7 @@ LoadIconImage(HINSTANCE hinst, LPCWSTR lpszName, INT width, INT height, UINT fuL
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//pick the best size.
|
/* Pick the best size. */
|
||||||
dirEntry = (CURSORICONDIRENTRY *)CURSORICON_FindBestIcon(IconDIR, width, height, 1);
|
dirEntry = (CURSORICONDIRENTRY *)CURSORICON_FindBestIcon(IconDIR, width, height, 1);
|
||||||
if (!dirEntry)
|
if (!dirEntry)
|
||||||
{
|
{
|
||||||
|
@ -407,12 +361,16 @@ LoadIconImage(HINSTANCE hinst, LPCWSTR lpszName, INT width, INT height, UINT fuL
|
||||||
}
|
}
|
||||||
|
|
||||||
SafeIconImage = RtlAllocateHeap(GetProcessHeap(), 0, dirEntry->dwBytesInRes);
|
SafeIconImage = RtlAllocateHeap(GetProcessHeap(), 0, dirEntry->dwBytesInRes);
|
||||||
|
if (SafeIconImage == NULL)
|
||||||
|
{
|
||||||
|
UnmapViewOfFile(IconDIR);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(SafeIconImage, ((PBYTE)IconDIR) + dirEntry->dwImageOffset, dirEntry->dwBytesInRes);
|
memcpy(SafeIconImage, ((PBYTE)IconDIR) + dirEntry->dwImageOffset, dirEntry->dwBytesInRes);
|
||||||
UnmapViewOfFile(IconDIR);
|
UnmapViewOfFile(IconDIR);
|
||||||
}
|
|
||||||
|
|
||||||
//at this point we have a copy of the icon image to play with
|
/* At this point we have a copy of the icon image to play with. */
|
||||||
|
|
||||||
SafeIconImage->icHeader.biHeight = SafeIconImage->icHeader.biHeight /2;
|
SafeIconImage->icHeader.biHeight = SafeIconImage->icHeader.biHeight /2;
|
||||||
|
|
||||||
|
@ -426,29 +384,26 @@ LoadIconImage(HINSTANCE hinst, LPCWSTR lpszName, INT width, INT height, UINT fuL
|
||||||
{
|
{
|
||||||
ColorCount = SafeIconImage->icHeader.biClrUsed;
|
ColorCount = SafeIconImage->icHeader.biClrUsed;
|
||||||
if (ColorCount == 0 && SafeIconImage->icHeader.biBitCount <= 8)
|
if (ColorCount == 0 && SafeIconImage->icHeader.biBitCount <= 8)
|
||||||
{
|
|
||||||
ColorCount = 1 << SafeIconImage->icHeader.biBitCount;
|
ColorCount = 1 << SafeIconImage->icHeader.biBitCount;
|
||||||
}
|
|
||||||
HeaderSize = sizeof(BITMAPINFOHEADER) + ColorCount * sizeof(RGBQUAD);
|
HeaderSize = sizeof(BITMAPINFOHEADER) + ColorCount * sizeof(RGBQUAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
//make data point to the start of the XOR image data
|
/* Make data point to the start of the XOR image data. */
|
||||||
Data = (PBYTE)SafeIconImage + HeaderSize;
|
Data = (PBYTE)SafeIconImage + HeaderSize;
|
||||||
|
|
||||||
|
/* Get a handle to the screen dc, the icon we create is going to be
|
||||||
//get a handle to the screen dc, the icon we create is going to be compatable with this
|
* compatable with this. */
|
||||||
hScreenDc = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
|
hScreenDc = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
|
||||||
if (hScreenDc == NULL)
|
if (hScreenDc == NULL)
|
||||||
{
|
{
|
||||||
if (fuLoad & LR_LOADFROMFILE)
|
if (fuLoad & LR_LOADFROMFILE)
|
||||||
{
|
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, SafeIconImage);
|
RtlFreeHeap(GetProcessHeap(), 0, SafeIconImage);
|
||||||
}
|
return NULL;
|
||||||
return(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hIcon = ICON_CreateIconFromData(hScreenDc, Data, SafeIconImage, width, height, width/2, height/2);
|
hIcon = ICON_CreateIconFromData(hScreenDc, Data, SafeIconImage, width, height, width/2, height/2);
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, SafeIconImage);
|
RtlFreeHeap(GetProcessHeap(), 0, SafeIconImage);
|
||||||
|
|
||||||
return hIcon;
|
return hIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,8 +414,8 @@ LoadBitmapImage(HINSTANCE hInstance, LPCWSTR lpszName, UINT fuLoad)
|
||||||
HANDLE hResource;
|
HANDLE hResource;
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
HANDLE hSection;
|
HANDLE hSection;
|
||||||
BITMAPINFO* BitmapInfo;
|
LPBITMAPINFO BitmapInfo;
|
||||||
BITMAPINFO* PrivateInfo;
|
LPBITMAPINFO PrivateInfo;
|
||||||
HDC hScreenDc;
|
HDC hScreenDc;
|
||||||
HANDLE hBitmap;
|
HANDLE hBitmap;
|
||||||
ULONG HeaderSize;
|
ULONG HeaderSize;
|
||||||
|
@ -470,63 +425,36 @@ LoadBitmapImage(HINSTANCE hInstance, LPCWSTR lpszName, UINT fuLoad)
|
||||||
if (!(fuLoad & LR_LOADFROMFILE))
|
if (!(fuLoad & LR_LOADFROMFILE))
|
||||||
{
|
{
|
||||||
if (hInstance == NULL)
|
if (hInstance == NULL)
|
||||||
{
|
hInstance = User32Instance;
|
||||||
hInstance = GetModuleHandleW(L"USER32");
|
|
||||||
}
|
|
||||||
hResource = FindResourceW(hInstance, lpszName, RT_BITMAP);
|
hResource = FindResourceW(hInstance, lpszName, RT_BITMAP);
|
||||||
if (hResource == NULL)
|
if (hResource == NULL)
|
||||||
{
|
return NULL;
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
hResource = LoadResource(hInstance, hResource);
|
hResource = LoadResource(hInstance, hResource);
|
||||||
if (hResource == NULL)
|
if (hResource == NULL)
|
||||||
{
|
return NULL;
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
BitmapInfo = LockResource(hResource);
|
BitmapInfo = LockResource(hResource);
|
||||||
if (BitmapInfo == NULL)
|
if (BitmapInfo == NULL)
|
||||||
{
|
return NULL;
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hFile = CreateFileW(lpszName,
|
hFile = CreateFileW(lpszName, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||||
GENERIC_READ,
|
OPEN_EXISTING, 0, NULL);
|
||||||
FILE_SHARE_READ,
|
|
||||||
NULL,
|
|
||||||
OPEN_EXISTING,
|
|
||||||
0,
|
|
||||||
NULL);
|
|
||||||
if (hFile == NULL)
|
if (hFile == NULL)
|
||||||
{
|
return NULL;
|
||||||
return(NULL);
|
|
||||||
}
|
hSection = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||||
hSection = CreateFileMappingW(hFile,
|
|
||||||
NULL,
|
|
||||||
PAGE_READONLY,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
NULL);
|
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
if (hSection == NULL)
|
if (hSection == NULL)
|
||||||
{
|
return NULL;
|
||||||
return(NULL);
|
|
||||||
}
|
BitmapInfo = MapViewOfFile(hSection, FILE_MAP_READ, 0, 0, 0);
|
||||||
BitmapInfo = MapViewOfFile(hSection,
|
|
||||||
FILE_MAP_READ,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
CloseHandle(hSection);
|
CloseHandle(hSection);
|
||||||
if (BitmapInfo == NULL)
|
if (BitmapInfo == NULL)
|
||||||
{
|
return NULL;
|
||||||
return(NULL);
|
|
||||||
}
|
BitmapInfo = (LPBITMAPINFO)((ULONG_PTR)BitmapInfo + sizeof(BITMAPFILEHEADER));
|
||||||
/* offset BitmapInfo by 14 bytes to acount for the size of BITMAPFILEHEADER
|
|
||||||
unfortunatly sizeof(BITMAPFILEHEADER) = 16, but the acutal size should be 14!
|
|
||||||
*/
|
|
||||||
BitmapInfo = (BITMAPINFO*)(((PBYTE)BitmapInfo) + 14);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BitmapInfo->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
|
if (BitmapInfo->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
|
||||||
|
@ -539,9 +467,7 @@ LoadBitmapImage(HINSTANCE hInstance, LPCWSTR lpszName, UINT fuLoad)
|
||||||
{
|
{
|
||||||
ColorCount = BitmapInfo->bmiHeader.biClrUsed;
|
ColorCount = BitmapInfo->bmiHeader.biClrUsed;
|
||||||
if (ColorCount == 0 && BitmapInfo->bmiHeader.biBitCount <= 8)
|
if (ColorCount == 0 && BitmapInfo->bmiHeader.biBitCount <= 8)
|
||||||
{
|
|
||||||
ColorCount = 1 << BitmapInfo->bmiHeader.biBitCount;
|
ColorCount = 1 << BitmapInfo->bmiHeader.biBitCount;
|
||||||
}
|
|
||||||
HeaderSize = sizeof(BITMAPINFOHEADER) + ColorCount * sizeof(RGBQUAD);
|
HeaderSize = sizeof(BITMAPINFOHEADER) + ColorCount * sizeof(RGBQUAD);
|
||||||
}
|
}
|
||||||
Data = (PVOID)((ULONG_PTR)BitmapInfo + HeaderSize);
|
Data = (PVOID)((ULONG_PTR)BitmapInfo + HeaderSize);
|
||||||
|
@ -550,10 +476,8 @@ LoadBitmapImage(HINSTANCE hInstance, LPCWSTR lpszName, UINT fuLoad)
|
||||||
if (PrivateInfo == NULL)
|
if (PrivateInfo == NULL)
|
||||||
{
|
{
|
||||||
if (fuLoad & LR_LOADFROMFILE)
|
if (fuLoad & LR_LOADFROMFILE)
|
||||||
{
|
|
||||||
UnmapViewOfFile(BitmapInfo);
|
UnmapViewOfFile(BitmapInfo);
|
||||||
}
|
return NULL;
|
||||||
return(NULL);
|
|
||||||
}
|
}
|
||||||
memcpy(PrivateInfo, BitmapInfo, HeaderSize);
|
memcpy(PrivateInfo, BitmapInfo, HeaderSize);
|
||||||
|
|
||||||
|
@ -564,10 +488,8 @@ LoadBitmapImage(HINSTANCE hInstance, LPCWSTR lpszName, UINT fuLoad)
|
||||||
{
|
{
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, PrivateInfo);
|
RtlFreeHeap(GetProcessHeap(), 0, PrivateInfo);
|
||||||
if (fuLoad & LR_LOADFROMFILE)
|
if (fuLoad & LR_LOADFROMFILE)
|
||||||
{
|
|
||||||
UnmapViewOfFile(BitmapInfo);
|
UnmapViewOfFile(BitmapInfo);
|
||||||
}
|
return NULL;
|
||||||
return(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fuLoad & LR_CREATEDIBSECTION)
|
if (fuLoad & LR_CREATEDIBSECTION)
|
||||||
|
@ -589,65 +511,51 @@ LoadBitmapImage(HINSTANCE hInstance, LPCWSTR lpszName, UINT fuLoad)
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, PrivateInfo);
|
RtlFreeHeap(GetProcessHeap(), 0, PrivateInfo);
|
||||||
DeleteDC(hScreenDc);
|
DeleteDC(hScreenDc);
|
||||||
if (fuLoad & LR_LOADFROMFILE)
|
if (fuLoad & LR_LOADFROMFILE)
|
||||||
{
|
|
||||||
UnmapViewOfFile(BitmapInfo);
|
UnmapViewOfFile(BitmapInfo);
|
||||||
}
|
|
||||||
return(hBitmap);
|
return hBitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE STDCALL
|
HANDLE STDCALL
|
||||||
LoadImageW(HINSTANCE hinst,
|
LoadImageW(
|
||||||
LPCWSTR lpszName,
|
IN HINSTANCE hinst,
|
||||||
UINT uType,
|
IN LPCWSTR lpszName,
|
||||||
int cxDesired,
|
IN UINT uType,
|
||||||
int cyDesired,
|
IN INT cxDesired,
|
||||||
UINT fuLoad)
|
IN INT cyDesired,
|
||||||
|
IN UINT fuLoad)
|
||||||
{
|
{
|
||||||
if (fuLoad & LR_DEFAULTSIZE)
|
if (fuLoad & LR_DEFAULTSIZE)
|
||||||
{
|
{
|
||||||
if (uType == IMAGE_ICON)
|
if (uType == IMAGE_ICON)
|
||||||
{
|
{
|
||||||
if (cxDesired == 0)
|
if (cxDesired == 0)
|
||||||
{
|
|
||||||
cxDesired = GetSystemMetrics(SM_CXICON);
|
cxDesired = GetSystemMetrics(SM_CXICON);
|
||||||
}
|
|
||||||
if (cyDesired == 0)
|
if (cyDesired == 0)
|
||||||
{
|
|
||||||
cyDesired = GetSystemMetrics(SM_CYICON);
|
cyDesired = GetSystemMetrics(SM_CYICON);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (uType == IMAGE_CURSOR)
|
else if (uType == IMAGE_CURSOR)
|
||||||
{
|
{
|
||||||
if (cxDesired == 0)
|
if (cxDesired == 0)
|
||||||
{
|
|
||||||
cxDesired = GetSystemMetrics(SM_CXCURSOR);
|
cxDesired = GetSystemMetrics(SM_CXCURSOR);
|
||||||
}
|
|
||||||
if (cyDesired == 0)
|
if (cyDesired == 0)
|
||||||
{
|
|
||||||
cyDesired = GetSystemMetrics(SM_CYCURSOR);
|
cyDesired = GetSystemMetrics(SM_CYCURSOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
switch (uType)
|
switch (uType)
|
||||||
{
|
{
|
||||||
case IMAGE_BITMAP:
|
case IMAGE_BITMAP:
|
||||||
{
|
return LoadBitmapImage(hinst, lpszName, fuLoad);
|
||||||
return(LoadBitmapImage(hinst, lpszName, fuLoad));
|
|
||||||
}
|
|
||||||
case IMAGE_CURSOR:
|
case IMAGE_CURSOR:
|
||||||
{
|
return LoadCursorImage(hinst, lpszName, fuLoad);
|
||||||
return(LoadCursorImage(hinst, lpszName, fuLoad));
|
|
||||||
}
|
|
||||||
case IMAGE_ICON:
|
case IMAGE_ICON:
|
||||||
{
|
return LoadIconImage(hinst, lpszName, cxDesired, cyDesired, fuLoad);
|
||||||
return(LoadIconImage(hinst, lpszName, cxDesired, cyDesired, fuLoad));
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
DbgBreakPoint();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return(NULL);
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -657,7 +565,7 @@ LoadImageW(HINSTANCE hinst,
|
||||||
HBITMAP STDCALL
|
HBITMAP STDCALL
|
||||||
LoadBitmapA(HINSTANCE hInstance, LPCSTR lpBitmapName)
|
LoadBitmapA(HINSTANCE hInstance, LPCSTR lpBitmapName)
|
||||||
{
|
{
|
||||||
return(LoadImageA(hInstance, lpBitmapName, IMAGE_BITMAP, 0, 0, 0));
|
return LoadImageA(hInstance, lpBitmapName, IMAGE_BITMAP, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -667,7 +575,7 @@ LoadBitmapA(HINSTANCE hInstance, LPCSTR lpBitmapName)
|
||||||
HBITMAP STDCALL
|
HBITMAP STDCALL
|
||||||
LoadBitmapW(HINSTANCE hInstance, LPCWSTR lpBitmapName)
|
LoadBitmapW(HINSTANCE hInstance, LPCWSTR lpBitmapName)
|
||||||
{
|
{
|
||||||
return(LoadImageW(hInstance, lpBitmapName, IMAGE_BITMAP, 0, 0, 0));
|
return LoadImageW(hInstance, lpBitmapName, IMAGE_BITMAP, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -675,7 +583,12 @@ LoadBitmapW(HINSTANCE hInstance, LPCWSTR lpBitmapName)
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
HANDLE WINAPI
|
HANDLE WINAPI
|
||||||
CopyImage(HANDLE hnd, UINT type, INT desiredx, INT desiredy, UINT flags)
|
CopyImage(
|
||||||
|
IN HANDLE hnd,
|
||||||
|
IN UINT type,
|
||||||
|
IN INT desiredx,
|
||||||
|
IN INT desiredy,
|
||||||
|
IN UINT flags)
|
||||||
{
|
{
|
||||||
HBITMAP res;
|
HBITMAP res;
|
||||||
BITMAP bm;
|
BITMAP bm;
|
||||||
|
@ -685,11 +598,12 @@ CopyImage(HANDLE hnd, UINT type, INT desiredx, INT desiredy, UINT flags)
|
||||||
case IMAGE_BITMAP:
|
case IMAGE_BITMAP:
|
||||||
{
|
{
|
||||||
DbgPrint("WARNING: Incomplete implementation of CopyImage!\n");
|
DbgPrint("WARNING: Incomplete implementation of CopyImage!\n");
|
||||||
/* FIXME: support flags LR_COPYDELETEORG, LR_COPYFROMRESOURCE,
|
/*
|
||||||
LR_COPYRETURNORG, LR_CREATEDIBSECTION,
|
* FIXME: Support flags LR_COPYDELETEORG, LR_COPYFROMRESOURCE,
|
||||||
and LR_MONOCHROME; */
|
* LR_COPYRETURNORG, LR_CREATEDIBSECTION and LR_MONOCHROME.
|
||||||
|
*/
|
||||||
if (!GetObjectW(hnd, sizeof(bm), &bm)) return 0;
|
if (!GetObjectW(hnd, sizeof(bm), &bm))
|
||||||
|
return NULL;
|
||||||
bm.bmBits = NULL;
|
bm.bmBits = NULL;
|
||||||
if ((res = CreateBitmapIndirect(&bm)))
|
if ((res = CreateBitmapIndirect(&bm)))
|
||||||
{
|
{
|
||||||
|
@ -705,26 +619,31 @@ CopyImage(HANDLE hnd, UINT type, INT desiredx, INT desiredy, UINT flags)
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IMAGE_ICON:
|
case IMAGE_ICON:
|
||||||
{
|
{
|
||||||
static BOOL IconMsgDisplayed = FALSE;
|
static BOOL IconMsgDisplayed = FALSE;
|
||||||
/* FIXME: support loading the image as shared from an instance */
|
/* FIXME: support loading the image as shared from an instance */
|
||||||
if (!IconMsgDisplayed) {
|
if (!IconMsgDisplayed)
|
||||||
|
{
|
||||||
DbgPrint("FIXME: CopyImage doesn't support IMAGE_ICON correctly!\n");
|
DbgPrint("FIXME: CopyImage doesn't support IMAGE_ICON correctly!\n");
|
||||||
IconMsgDisplayed = TRUE;
|
IconMsgDisplayed = TRUE;
|
||||||
}
|
}
|
||||||
return CopyIcon(hnd);
|
return CopyIcon(hnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
case IMAGE_CURSOR:
|
case IMAGE_CURSOR:
|
||||||
{
|
{
|
||||||
static BOOL IconMsgDisplayed = FALSE;
|
static BOOL IconMsgDisplayed = FALSE;
|
||||||
/* FIXME: support loading the image as shared from an instance */
|
/* FIXME: support loading the image as shared from an instance */
|
||||||
if (!IconMsgDisplayed) {
|
if (!IconMsgDisplayed)
|
||||||
|
{
|
||||||
DbgPrint("FIXME: CopyImage doesn't support IMAGE_CURSOR correctly!\n");
|
DbgPrint("FIXME: CopyImage doesn't support IMAGE_CURSOR correctly!\n");
|
||||||
IconMsgDisplayed = TRUE;
|
IconMsgDisplayed = TRUE;
|
||||||
}
|
}
|
||||||
return CopyCursor(hnd);
|
return CopyCursor(hnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue