Which Method or Function give the handle for Cwindow Seticon?
Found it..
Cimage img;
hicon = img.LoadFromFile(path);
I'd like to your see code when you have it finished, will be using this to study. What do you do with hicon?
hicon contain the handle to an .ico file (can be other image format too)
you can do lots of thing with that.
what i've done with it is simply add the icon to the window caption of my program
use seticon(hicon); after calling the above to set to the caption
little quick example:
in your sub main() after creating the window or in OnInitDialog() for a dialog
Mywindow win;
Cimage img;
string path;
int hicon;
path = "...\\path to the file";
hicon = img.LoadFromFile(path);
win.seticon(hicon);
I see, ok cool, thanks will be neat to play with too!!
Use CIcon instead.
CIcon i;
i.LoadFromFile(path);
win.SetIcon(i.Detach());
interresting,
i was wondering how i can get the handle with Cicon since it was not returning anything ;)
thanx!
Detach removes the handle from the class so it doesn't destroy it when the object is destroyed. Normally when a class object goes out of scope (by DELETEing it or when a subroutine ends) CIcon will destroy the handle.
By using window.SetIcon(icon.Detach()) you are giving the handle to the window and it is then responsible for freeing the icon when the window closes, which happens automatically.