fltkhs-demos
fltkhs-demos copied to clipboard
Add application icon example
I'm trying to assign an application icon in a Windows application but fail to convert the type.
So fare I've created a Windows resource file, resources.rc:
101 ICON DISCARDABLE "App.ico"
and compiled it windres resources.rc -O coff -o resources.res, linked it to my application using an ld-options: resources.res entry in my cabal file.
So now my application has the App.ico when seeing it listed in Windows explorer.
But I also want to see this icon in my main window, so
import Graphics.Win32
....
ico <- loadIcon Nothing (castUINTPtrToPtr 101)
ico_ptr <- newForeignPtr_ $ castPtr ico
main_window `setIcon` (Just (Ref ico_ptr))
gives the error:
Couldn't match type Graphics.UI.FLTK.LowLevel.Dispatch.FindInHierarchy
a0 a0 (Graphics.UI.FLTK.LowLevel.Hierarchy.CImage Base)
with Graphics.UI.FLTK.LowLevel.Dispatch.InHierarchy
Do you have any idea how to convert this to the correct type?
I'm using this issue so perhaps once solved can be added to the other demos.
rgbImageNew takes a ByteString, so is there anyway to extract an RGB image as an array of bytes from your icon? I don't know the Win32 API. Also once solved adding this to the set of demos sounds like a great idea!
@jputcu can you share the whole program?