RE: Win API question
- Posted by Brian Broker <bkb at cnw.com> Dec 10, 2003
- 487 views
Hi Philip, Here's a demo that extracts the large and small icons directly from shell32.dll: include win32lib.ew without warning constant Win = create( Window, "Win", 0, Default, Default, 100, 100, 0 ), Big_Icon = create( Icon, "", Win, 35, 20, 0, 0, 0 ), Small_Icon = create( Icon, "", Win, 10, 20, 0, 0, 0 ) constant xExtractIconEx = registerw32Function(shell32, "ExtractIconExA", {C_POINTER, C_INT, C_POINTER, C_POINTER, C_UINT}, C_UINT) procedure init( integer self, integer event, sequence params ) integer icon atom lpszFile, phiconLarge, phiconSmall lpszFile = allocate_string( "shell32.dll" ) phiconLarge = allocate(4) phiconSmall = allocate(4) -- get total number of icons in file --icon = w32Func( xExtractIconEx, { lpszFile, -1, 0, 0, 0 } ) -- extract large and small txt doc icons icon = w32Func( xExtractIconEx, { lpszFile, 70, phiconLarge, phiconSmall, 1 } ) setIcon( Small_Icon, peek4u(phiconSmall) ) setIcon( Big_Icon, peek4u(phiconLarge) ) -- compare small icon to squished large icon in window setIcon( Win, peek4u(phiconLarge) ) free( lpszFile ) free( phiconLarge ) free( phiconSmall ) end procedure setHandler( Win,w32HOpen,routine_id("init") ) WinMain( Win, Normal ) -- Brian Philip Deets wrote: > > > I just tried every number from 1 to 10, none of them look any different, > > they all look crammed. > > Also, where can I find an icon editor? I don't have one. > > Phil > > > ------ > > Bernie Ryan wrote: > > >Yes, but how do I get it to display the 16x16 version of the icon > >instead of the crammed 32x32 version? > > Philip: > > I look at the ICON used on NotePad and it contains 8 icons. > first, forth, and eight icons are the smallest icons. > > icon = addIcon( w32Func( xExtractAssociatedIcon, > { 0, "C:\\myfile.txt", 0 } ) ) > > In the last parameter you used index zero which will try to use a > default > because you didn't use a specific index. > > Try using 1, 4, or 8 in the last parameter. > > Bernie > >