🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #199

Re: Loading x48 icons with ExtractIconEx...

#199
From: Bob Gonder
Date: Wed, 02 Jul 2008 20:38
47 lines
2593 bytes
Mike Collins wrote:

>I'll stick a demo app on the .attachments group if you want to have a look.

Ok, in a nutshell, here it is (from the "Icons in Win32" link).
Filter your results on e->bWidth or height.

{
	String Filename = FileListBox->FileName;	// full path
	HMODULE hLib = LoadLibraryEx( Filename.c_str(), NULL, LOAD_LIBRARY_AS_DATAFILE );
	EnumResourceNames( hLib, RT_GROUP_ICON,
			(ENUMRESNAMEPROC)EnumNamesFunc, 0 );
	FreeLibrary( hLib );
}

BOOL EnumNamesFunc(
	HANDLE hModule,   // module handle
	LPCTSTR lpType,   // address of resource type
	LPTSTR lpName,    // address of resource name
	LONG lParam)      // extra parameter
{
	HRSRC hRsrc = FindResource( hModule, lpName, lpType );
	HGLOBAL hGroup = LoadResource( hModule, hRsrc );
	GRPICONDIR * lpGrpIconDir = (LPGRPICONDIR)LockResource( hGroup );
	for( int i=0; i < lpGrpIconDir->idCount; ++i )
	{
		int x = (i%7)*64;
		int y = (i/8)*64;

		GRPICONDIRENTRY * e = &lpGrpIconDir->idEntries[i];
		hRsrc = FindResource( hModule, MAKEINTRESOURCE( e->nID ), RT_ICON );
		HGLOBAL hGlobal = LoadResource( hModule, hRsrc );
		ICONIMAGE *lpIconImage = (LPICONIMAGE)LockResource( hGlobal );
		HICON hicon = CreateIconFromResourceEx(
						(PBYTE)lpIconImage,
						e->dwBytesInRes,
						TRUE,
						0x00030000,//DWORD dwVersion,
						e->bWidth,
						e->bHeight,
						0 );
		TIcon *icon = new TIcon;
		icon->Handle = hicon;
		Form2->Image1->Canvas->Draw( x, y, icon );
	};
	return TRUE;
}
Technical Details
Message-ID: <nion645ihefqe5tua1emrg8hl9jt11jb8r@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!feeder.erje.net!news.isoc.lu!newsgroups.borland.com!not-for-mail
References: <486960ab@newsgroups.borland.com> <d73j6491uh8j0ess67ai2ht5jdkj5remsf@4ax.com> <486a0d3d$1@newsgroups.borland.com> <bdgk64p9sfo43qu90s1plgmf08v9h4m6rp@4ax.com> <486a50aa@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,bcbc54027817c35e
X-Google-Attributes: gid10cc67,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <none@nowhere.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Loading x48 icons with ExtractIconEx...
Date: Wed, 02 Jul 2008 13:38:51 -0700
Message-ID: <nion645ihefqe5tua1emrg8hl9jt11jb8r@4ax.com>
References: <486960ab@newsgroups.borland.com> <d73j6491uh8j0ess67ai2ht5jdkj5remsf@4ax.com> <486a0d3d$1@newsgroups.borland.com> <bdgk64p9sfo43qu90s1plgmf08v9h4m6rp@4ax.com> <486a50aa@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 67.77.146.152
X-Trace: newsgroups.borland.com 1215031128 67.77.146.152 (2 Jul 2008 13:38:48 -0700)
Lines: 51
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!feeder.erje.net!news.isoc.lu!newsgroups.borland.com!not-for-mail