The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: xandaz on September 17, 2010, 07:30:44 PM

Title: LookupIconIdFromDirectory ???
Post by: xandaz on September 17, 2010, 07:30:44 PM
   Hi there. I've been trying to find icon id's for RT_GROUP_ICON and ..._CURSOR in resource files but i've been unsuccessful. I'm posting the code. Hope someone sees what's wrong.
invoke FindResource,lpszName,lpszType
mov hResFind,eax
invoke LoadResource,hResource,hResFind
invoke LockResource,eax
invoke LookupIconIdFromDirectory,eax,FALSE
invoke FindResource,eax,lpszType
mov hResFind,eax
invoke LoadResource,hResource,hResFind
mov hResLoad,eax
invoke LockResource,eax
mov lpRes,eax
invoke SizeofResource,hResource,hResFind
invoke CreateIconFromResource,lpRes,eax,FALSE,030000h
push eax
invoke ImageList_AddIcon,hList,eax
mov lvi.iImage,eax
invoke SendMessage,hListView,LVM_INSERTITEM,NULL,addr lvi
pop eax
invoke DestroyIcon,eax


Thanks guys and bye
Title: Re: LookupIconIdFromDirectory ???
Post by: xandaz on September 17, 2010, 10:35:32 PM
   Looked around and found the fix for it. The Second time FindResource is called, right after the LookipIconIdFromDirectory, lpszType must be RT_ICON/RT_CURSOR and not RT_GROUP_ICON/CURSOR. So it becomes like this

invoke FindResource,lpszName,lpszType
mov hResFind,eax
invoke LoadResource,hResource,hResFind
invoke LockResource,eax
invoke LookupIconIdFromDirectory,eax,FALSE ; False because its a cursor
invoke FindResource,eax,RT_CURSOR
mov hResFind,eax
invoke LoadResource,hResource,hResFind
mov hResLoad,eax
invoke LockResource,eax
mov lpRes,eax
invoke SizeofResource,hResource,hResFind
invoke CreateIconFromResource,lpRes,eax,FALSE,030000h
push eax
invoke ImageList_AddIcon,hList,eax
mov lvi.iImage,eax
invoke SendMessage,hListView,LVM_INSERTITEM,NULL,addr lvi
pop eax
invoke DestroyIcon,eax