IonicWind Software

Aurora Compiler => GUI => Topic started by: ExMember001 on August 21, 2006, 02:47:03 PM

Title: icon handle
Post by: ExMember001 on August 21, 2006, 02:47:03 PM
Which Method or Function give the handle for Cwindow Seticon?
Title: Re: icon handle
Post by: ExMember001 on August 21, 2006, 11:05:09 PM
Found it..

Cimage img;
hicon = img.LoadFromFile(path);
Title: Re: icon handle
Post by: kryton9 on August 22, 2006, 12:38:27 AM
I'd like to your see code when you have it finished, will be using this to study. What do you do with hicon?
Title: Re: icon handle
Post by: ExMember001 on August 22, 2006, 01:52:07 AM
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);
Title: Re: icon handle
Post by: kryton9 on August 22, 2006, 02:51:20 AM
I see, ok cool, thanks will be neat to play with too!!
Title: Re: icon handle
Post by: Ionic Wind Support Team on August 22, 2006, 04:41:10 AM
Use CIcon instead.

CIcon i;
i.LoadFromFile(path);
win.SetIcon(i.Detach());

Title: Re: icon handle
Post by: ExMember001 on August 22, 2006, 12:38:01 PM
interresting,
i was wondering how i can get the handle with Cicon since it was not returning anything ;)
thanx!
Title: Re: icon handle
Post by: Ionic Wind Support Team on August 22, 2006, 12:46:13 PM
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.