RE: Win API question

new topic     » goto parent     » topic index » view thread      » older message » newer message

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu