-
April 22nd, 2009, 12:12 AM
#1
C++ Winapi - Imagelist
GetLastError returns error 1813 - ERROR_RESOURCE_TYPE_NOT_FOUND during LoadIcon
Any Ideas?
Code:
HIMAGELIST hList = ImageList_Create(32, 32, ILC_COLOR, 1, 1);
if(hList == NULL)
{
MessageBox(hwnd, "ImageList_Create failed!", "Notice", MB_OK);
char eBuf[100] = {0};
sprintf(eBuf, "%d", GetLastError());
MessageBox(hwnd, "LoadImage failed!", eBuf, MB_OK);
}
HICON hItem = LoadIcon(NULL, MAKEINTRESOURCE(aIcon));
if(hItem == NULL)
{
char eBuf[100] = {0};
sprintf(eBuf, "%d", GetLastError());
MessageBox(hwnd, "LoadImage failed!", eBuf, MB_OK);
}
ImageList_AddIcon( hList, hItem );
DeleteObject( hItem );
// Make the listview use the images lists and exit
ListView_SetImageList( listview, hList, LVSIL_NORMAL );
Code:
//Rc
aIcon ICON "defUninstaller.ico"
//.h
#define aIcon 4
Last edited by zaryk; April 22nd, 2009 at 12:30 AM.
-
April 22nd, 2009, 12:53 PM
#2
Re: C++ Winapi - Imagelist
Solved.
Code:
HIMAGELIST hList = ImageList_Create(32, 32, ILC_COLOR, 1, 1);
if(hList == NULL)
{
char eBuf[100] = {0};
sprintf(eBuf, "%d", GetLastError());
MessageBox(hwnd, "ImageList_Create failed!", eBuf, MB_OK);
}
HICON hItem = (HICON)LoadImage(0, (LPCTSTR)"defUninstaller.ico", IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
if(hItem == NULL)
{
char eBuf[100] = {0};
sprintf(eBuf, "%d", GetLastError());
MessageBox(hwnd, "LoadImage failed!", eBuf, MB_OK);
}
ImageList_AddIcon( hList, hItem );
DeleteObject( hItem );
// Make the listview use the images lists and exit
ListView_SetImageList( listview, hList, LVSIL_NORMAL );
-
April 30th, 2009, 10:52 AM
#3
Re: C++ Winapi - Imagelist
This Returns ERROR_RESOURCE_TYPE_NOT_FOUND 1813L. Any ideas on how to get this to work? I just need icon 1025 from shell32.dll at the moment.
Code:
HIMAGELIST hList = ImageList_Create(32, 32, ILC_COLOR, 1, 1);
if(hList == NULL)
{
char eBuf[100] = {0};
sprintf(eBuf, "%d", GetLastError());
MessageBox(hwnd, "ImageList_Create failed!", eBuf, MB_OK);
}
HINSTANCE hLib = LoadLibrary((LPCTSTR)"shell32.dll");
if(hLib == NULL)
{
char eBuf[100] = {0};
sprintf(eBuf, "%d", GetLastError());
MessageBox(hwnd, "LoadLibrary failed!", eBuf, MB_OK);
}
HICON hItem = (HICON)LoadImage(hLib, MAKEINTRESOURCE(1025), IMAGE_ICON, 0, 0, LR_SHARED);
if(hItem == NULL)
{
char eBuf[100] = {0};
sprintf(eBuf, "%d", GetLastError());
MessageBox(hwnd, "LoadImage failed!", eBuf, MB_OK);
}
ImageList_AddIcon( hList, hItem );
DeleteObject( hItem );
// Make the listview use the images lists and exit
ListView_SetImageList( listview, hList, LVSIL_NORMAL );
-
April 30th, 2009, 04:22 PM
#4
Re: C++ Winapi - Imagelist
Changed it to this.
Code:
HIMAGELIST hList = ImageList_Create(32, 32, ILC_COLOR, 1, 1);
if(hList == NULL)
{
char eBuf[100] = {0};
sprintf(eBuf, "%d", GetLastError());
MessageBox(hwnd, "ImageList_Create failed!", eBuf, MB_OK);
}
HICON hItem = ExtractIcon(0, (LPCTSTR)"shell32.dll", 1025);
if(hItem != ERROR_SUCCESS)
{
char eBuf[100] = {0};
sprintf(eBuf, "%d", GetLastError());
MessageBox(hwnd, "LoadImage failed!", eBuf, MB_OK);
}
ImageList_AddIcon( hList, hItem );
DeleteObject( hItem );
// Make the listview use the images lists and exit
ListView_SetImageList( listview, hList, LVSIL_NORMAL );
-
April 30th, 2009, 08:04 PM
#5
Re: C++ Winapi - Imagelist
Figured out why it was returning an error. I was using resource hacker to check the resource i wanted, and I created a little program to extract the icons from shell32.dll and found out that resource hacker displays a lot more icons than what my little program was displaying....so the icon I needed was 162 not 1025. This was the error because my little program only goes up to 237.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|