1. RE: Win API question
- Posted by Brian Broker <bkb at cnw.com> Dec 09, 2003
- 526 views
Phil, Both the second and third parameters for ExtractAssociatedIcon are pointers. It took some experimentation but this works... include win32lib.ew without warning constant Win = create( Window, "Win", 0, Default, Default, 100, 100, 0 ), Icn = create( Icon, "", Win, 35, 20, 32, 32, 0 ) constant xExtractAssociatedIcon = registerw32Function(shell32, "ExtractAssociatedIconA", {C_INT, C_POINTER, C_POINTER}, C_INT) procedure init( integer self, integer event, sequence params ) atom lpIconPath, lpiIcon, icon lpIconPath = allocate_string( "C:\\myfile.txt" ) lpiIcon = allocate(4) poke4(lpiIcon,0) icon = w32Func( xExtractAssociatedIcon, { instance(), lpIconPath,lpiIcon } ) setIcon( Icn, icon ) end procedure setHandler( Win,w32HOpen,routine_id("init") ) WinMain( Win, Normal ) -- Brian Philip Deets wrote: > > > Can someone tell me why this won't work? > > It should put a notepad icon on the window. Make sure you make a file > "C:\myfile.txt" before you run the program. > > --begin code > > include win32lib.ew > without warning > > constant win = create( Window, "win", 0, Default, Default, 500, 500, 0 ) > > constant xExtractAssociatedIcon = > registerw32Function(shell32, "ExtractAssociatedIconA", {C_INT, > C_POINTER, C_INT}, C_INT), > icon = addIcon( w32Func( xExtractAssociatedIcon, { 0, "C:\\myfile.txt", > 0 } ) ) > > > procedure paintWin( integer self, integer event, sequence parms ) > > copyBlt( win, 10, 10, icon ) > > end procedure > setHandler( win, w32HPaint, routine_id( "paintWin" ) ) > > WinMain( win, Normal ) > > --end code > > Thanks, > > Phil > >
2. RE: Win API question
- Posted by Brian Broker <bkb at cnw.com> Dec 09, 2003
- 492 views
Philip, Not a real big deal but I forgot to free my pointers when I was done with them so for the sake of completeness and "good housekeeping": include win32lib.ew without warning constant Win = create( Window, "Win", 0, Default, Default, 100, 100, 0 ), Icn = create( Icon, "", Win, 35, 20, 32, 32, 0 ) constant xExtractAssociatedIcon = registerw32Function(shell32, "ExtractAssociatedIconA", {C_INT, C_POINTER, C_POINTER}, C_INT) procedure init( integer self, integer event, sequence params ) atom lpIconPath, lpiIcon, icon lpIconPath = allocate_string( "C:\\myfile.txt" ) lpiIcon = allocate(4) poke4(lpiIcon,0) icon = w32Func( xExtractAssociatedIcon, { instance(), lpIconPath,lpiIcon } ) setIcon( Icn, icon ) free( lpIconPath ) free( lpiIcon ) end procedure setHandler( Win,w32HOpen,routine_id("init") ) WinMain( Win, Normal ) -- Brian Philip Deets wrote: > > > Can someone tell me why this won't work? > > It should put a notepad icon on the window. Make sure you make a file > "C:\myfile.txt" before you run the program. > > --begin code > > include win32lib.ew > without warning > > constant win = create( Window, "win", 0, Default, Default, 500, 500, 0 ) > > constant xExtractAssociatedIcon = > registerw32Function(shell32, "ExtractAssociatedIconA", {C_INT, > C_POINTER, C_INT}, C_INT), > icon = addIcon( w32Func( xExtractAssociatedIcon, { 0, "C:\\myfile.txt", > 0 } ) ) > > > procedure paintWin( integer self, integer event, sequence parms ) > > copyBlt( win, 10, 10, icon ) > > end procedure > setHandler( win, w32HPaint, routine_id( "paintWin" ) ) > > WinMain( win, Normal ) > > --end code > > Thanks, > > Phil > >
3. RE: Win API question
- Posted by "Philip Deets" <philip1987 at hotmail.com> Dec 09, 2003
- 492 views
Thanks, it worked :) Now my editor (unreleased so far) has icons for all the files in the file view window on the left. The icons look squeezed though. Can I do anything about that? Is Windows just cramming a 32 x 32 icon into a 16 x 16 treeview Icon space. If there's something I can do about the squeezed look (like get a 16 x 16 icon), please let me know. Thanks, Phil -------- Brian Broker wrote: Philip, Not a real big deal but I forgot to free my pointers when I was done with them so for the sake of completeness and "good housekeeping": include win32lib.ew without warning constant Win = create( Window, "Win", 0, Default, Default, 100, 100, 0 ), Icn = create( Icon, "", Win, 35, 20, 32, 32, 0 ) constant xExtractAssociatedIcon = registerw32Function(shell32, "ExtractAssociatedIconA", {C_INT, C_POINTER, C_POINTER}, C_INT) procedure init( integer self, integer event, sequence params ) atom lpIconPath, lpiIcon, icon lpIconPath = allocate_string( "C:\\myfile.txt" ) lpiIcon = allocate(4) poke4(lpiIcon,0) icon = w32Func( xExtractAssociatedIcon, { instance(), lpIconPath,lpiIcon } ) setIcon( Icn, icon ) free( lpIconPath ) free( lpiIcon ) end procedure setHandler( Win,w32HOpen,routine_id("init") ) WinMain( Win, Normal ) -- Brian Philip Deets wrote: > > > Can someone tell me why this won't work? > > It should put a notepad icon on the window. Make sure you make a file > "C:\myfile.txt" before you run the program. > > --begin code > > include win32lib.ew > without warning > > constant win = create( Window, "win", 0, Default, Default, 500, 500, 0 ) > > constant xExtractAssociatedIcon = > registerw32Function(shell32, "ExtractAssociatedIconA", {C_INT, > C_POINTER, C_INT}, C_INT), > icon = addIcon( w32Func( xExtractAssociatedIcon, { 0, "C:\\myfile.txt", > 0 } ) ) > > > procedure paintWin( integer self, integer event, sequence parms ) > > copyBlt( win, 10, 10, icon ) > > end procedure > setHandler( win, w32HPaint, routine_id( "paintWin" ) ) > > WinMain( win, Normal ) > > --end code > > Thanks, > > Phil
4. RE: Win API question
- Posted by Brian Broker <bkb at cnw.com> Dec 09, 2003
- 481 views
Hi Philip, Yes, Windows is cramming a 32x32 icon into a 16x16 space. Unfortunately, I haven't yet figured out how to get the smaller icon (like the one displayed in explorer with "List" or "Details" view). If I figure it out, I'll let you know (unless somebody chimes in with a *tested* demo). -- Brian Philip Deets wrote: > > > Thanks, it worked :) Now my editor (unreleased so far) has icons for > all > the files in the file view window on the left. The icons look squeezed > though. Can I do anything about that? Is Windows just cramming a 32 x > 32 > icon into a 16 x 16 treeview Icon space. If there's something I can do > about the squeezed look (like get a 16 x 16 icon), please let me know. > > Thanks, > > Phil >
5. RE: Win API question
- Posted by "Bernard W. Ryan" <xotron at bluefrognet.net> Dec 10, 2003
- 504 views
Philip: The size of the icon depends on where it will be displayed on the large icon, small icon, minimized icon, alt-tab icon, etc. The icon must contain all the needed SIZES if you don't want it to be compressed. A window's icon resource ( or .ico file ) contains a 16x16, 32x32 and 48x48. This icon can also contain these 3 icons in in different color pallete sizes ( a total 9 possible combinations ). When windows displays an icon it selects the appropriate available icon to display OR it tries to select and adjust the icon size to fit the needed size and uses the nearest color pallet that is available for that icon. A good icon editor will allow you to see what sizes an ICO file file contains. Bernie
6. RE: Win API question
- Posted by Philip D. <philip1987 at hotmail.com> Dec 10, 2003
- 480 views
Bernard W. Ryan wrote: > > > Philip: > > The size of the icon depends on where it will be displayed > on the large icon, small icon, minimized icon, alt-tab icon, etc. > The icon must contain all the needed SIZES if you don't want it > to be compressed. > > A window's icon resource ( or .ico file ) contains a 16x16, 32x32 > and 48x48. This icon can also contain these 3 icons in > in different color pallete sizes ( a total 9 possible combinations ). > When windows displays an icon it selects the appropriate available > icon to display OR it tries to select and adjust the icon size to fit > the needed size and uses the nearest color pallet that is available > for that icon. > > A good icon editor will allow you to see what sizes an ICO file > file contains. > > Bernie > Yes, but how do I get it to display the 16x16 version of the icon instead of the crammed 32x32 version?
7. RE: Win API question
- Posted by "Bernard W. Ryan" <xotron at bluefrognet.net> Dec 10, 2003
- 483 views
>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
8. RE: Win API question
- Posted by "Philip Deets" <philip1987 at hotmail.com> Dec 10, 2003
- 487 views
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
9. RE: Win API question
- Posted by Brian Broker <bkb at cnw.com> Dec 10, 2003
- 488 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 > >
10. RE: Win API question
- Posted by "Philip Deets" <philip1987 at hotmail.com> Dec 10, 2003
- 497 views
Ok, I see that is one way I could get the small icon, but is there a way for me to know what file to look in? That is why I was using getAssociatedIcon, because I won't know what file to look in for the icon. How can I get small icons with the getAssociatedIcon function? ------ Brian Broker wrote: 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 >
11. RE: Win API question
- Posted by Brian Broker <bkb at cnw.com> Dec 10, 2003
- 490 views
You can't get the small icon using ExtractAssociatedIcon. The CreateIconFromResource, DrawIcon, ExtractAssociatedIcon, ExtractIcon, ExtractIconEx, and LoadIcon functions all use system large icons. If I figure out a way to do it, I'll let you know... -- Brian Philip Deets wrote: > > > Ok, I see that is one way I could get the small icon, but is there a way > for > me to know what file to look in? That is why I was using > getAssociatedIcon, > because I won't know what file to look in for the icon. How can I get > small > icons with the getAssociatedIcon function? > > ------ > > Brian Broker wrote: > > 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 > > >
12. RE: Win API question
- Posted by Johnny N. <jlnoble at frontiernet.net> Dec 11, 2003
- 503 views
Try this it's free! http://www.axiomx.com/PixelToolbox/index.htm Have fun! Johnny Derek Parnell wrote: > > > Mircoangelo is one of the better ones, but it costs. > ----- Original Message ----- > From: "Philip D." <philip1987 at hotmail.com> > To: <EUforum at topica.com> > Subject: RE: Win API question > > > > 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 > > > > > > TOPICA - Start your own email discussion group. FREE! > > > >
13. RE: Win API question
- Posted by Philip D. <philip1987 at hotmail.com> Dec 11, 2003
- 516 views
I figured it out :) Here's a demo that will give the small icon for an associated file. --begin code include win32lib.ew without warning constant Win = create( Window, "Win", 0, Default, Default, 100, 100, 0 ), Icn = create( Icon, "", Win, 35, 20, 16, 16, 0 ) constant xSHGetFileInfo = registerw32Function( shell32, "SHGetFileInfoA", { C_POINTER, C_INT, C_POINTER, C_INT, C_INT }, C_INT ) constant hIcon = allot( Hndl ), iIcon = allot( Int32 ), dwAttributes = allot( DWord ), szDisplayName = allot( Strz ), szTypeName = allot( Strz ), SIZEOF_SHFILEINFO = allotted_size() function getSmallIcon( sequence path ) atom pszPath, SHFileInfo_STRUCT, icon, mem mem = new_memset() SHFileInfo_STRUCT = acquire_mem( mem, SIZEOF_SHFILEINFO ) pszPath = allocate_string( path ) VOID = w32Func( xSHGetFileInfo, { pszPath, 0, SHFileInfo_STRUCT, SIZEOF_SHFILEINFO, or_all( { SHGFI_ICON, SHGFI_SMALLICON } ) } ) icon = fetch( SHFileInfo_STRUCT, hIcon ) free( pszPath ) release_mem( mem ) return icon end function procedure clickWin( integer self, integer event, sequence params ) setIcon( Icn, getSmallIcon( getOpenFileName(Win, "", {}) ) ) end procedure setHandler( Win, w32HClick, routine_id( "clickWin" ) ) WinMain( Win, Normal ) --end code Thanks for your help, Phil Brian Broker wrote: > > > You can't get the small icon using ExtractAssociatedIcon. The > CreateIconFromResource, DrawIcon, ExtractAssociatedIcon, ExtractIcon, > ExtractIconEx, and LoadIcon functions all use system large icons. If I > figure out a way to do it, I'll let you know... > > -- Brian > > Philip Deets wrote: > > > > > > Ok, I see that is one way I could get the small icon, but is there a way > > > > for > > me to know what file to look in? That is why I was using > > getAssociatedIcon, > > because I won't know what file to look in for the icon. How can I get > > small > > icons with the getAssociatedIcon function? > > > > ------ > > > > Brian Broker wrote: > > > > 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 <snip>